Raster Data
Raster Data
Datasets below are either included in the Essential or Complete setup script on the Setup page, or can be downloaded individually with the scripts here.
The full-size Sentinel-2 GeoTIFFs from the Essential and Complete bundles (e.g. nyc_sentinel2_red.tif, london_sentinel2_red.tif) are suitable for visual inspection in QGIS or other desktop viewers. Minimal or clipped Sentinel-2 rasters (including *_byte.tif human-friendly versions used in the minimal bundle or small extracts) may appear black or very dark when viewed—they are intended for processing and automated tests, not for visual quality. For best viewing results, use the full Essential or Complete bundle rasters.
Sentinel-2 Imagery via STAC (NYC Area)
Included in the Essential setup script.
Search and download Sentinel-2 imagery using STAC (SpatioTemporal Asset Catalog) - the modern standard for satellite data discovery.
# Install pystac-client if needed
%pip install pystac-client planetary-computer --quiet
# Search and download Sentinel-2 imagery over NYC
import pystac_client
import planetary_computer
import requests
from pathlib import Path
from databricks.labs.gbx.rasterx import functions as rx
sample_path = "/Volumes/main/default/geobrix_samples/geobrix-examples"
# Configure
rx.register(spark)
output_dir = Path(f"{sample_path}/nyc/sentinel2")
output_dir.mkdir(parents=True, exist_ok=True)
# Connect to Microsoft Planetary Computer STAC API
catalog = pystac_client.Client.open(
"https://planetarycomputer.microsoft.com/api/stac/v1",
modifier=planetary_computer.sign_inplace,
)
# Define NYC bounding box (approximate)
nyc_bbox = [-74.25, 40.50, -73.70, 40.92] # [west, south, east, north]
# Search for Sentinel-2 scenes
search = catalog.search(
collections=["sentinel-2-l2a"],
bbox=nyc_bbox,
datetime="2023-06-01/2023-08-31", # Summer for less clouds
query={
"eo:cloud_cover": {"lt": 20} # Less than 20% cloud cover
},
limit=5
)
items = list(search.items())
print(f"Found {len(items)} Sentinel-2 scenes over NYC")
if items:
# Get the least cloudy scene
best_item = min(items, key=lambda x: x.properties.get("eo:cloud_cover", 100))
print(f"Selected scene: {best_item.id}")
print(f" Date: {best_item.datetime}")
print(f" Cloud cover: {best_item.properties.get('eo:cloud_cover')}%")
# Download Red band (B04) - 10m resolution
red_band = best_item.assets["B04"]
red_url = red_band.href
output_file = output_dir / "nyc_sentinel2_red.tif"
print(f"Downloading Red band (~30MB)...")
response = requests.get(red_url, stream=True)
response.raise_for_status()
with open(output_file, 'wb') as f:
for chunk in response.iter_content(chunk_size=8192):
f.write(chunk)
file_size = output_file.stat().st_size / (1024 * 1024)
print(f"✅ Downloaded Sentinel-2 Red band ({file_size:.1f} MB)")
print(f" Path: {output_file}")
# Verify
raster = spark.read.format("gdal").load(str(output_file))
raster.select(
rx.rst_width("tile").alias("width"),
rx.rst_height("tile").alias("height"),
rx.rst_numbands("tile").alias("bands"),
rx.rst_pixelwidth("tile").alias("pixel_size")
).show()
Found 5 Sentinel-2 scenes over NYC
Selected scene: S2A_MSIL2A_20230715...
Date: 2023-07-15
Cloud cover: 8%
✅ Downloaded Sentinel-2 Red band (32.1 MB)
Path: .../nyc/sentinel2/nyc_sentinel2_red.tif
+-----+------+-----+-----------+
|width|height|bands|pixel_size |
+-----+------+-----+-----------+
|10980|10980 |1 |10.0 |
+-----+------+-----+-----------+
Usage in examples:
sample_path = "/Volumes/main/default/geobrix_samples/geobrix-examples"
sentinel_nyc = spark.read.format("gdal").load(f"{sample_path}/nyc/sentinel2/nyc_sentinel2_red.tif")
- Search by location, date, and cloud cover
- Access multiple bands (RGB, NIR, SWIR)
- Get the freshest available imagery
- Industry-standard metadata
Sentinel-2 Imagery via STAC (London Area)
Included in the Essential setup script.
Search and download Sentinel-2 imagery over London - perfect for UK GridX BNG examples.
# Install pystac-client if needed
%pip install pystac-client planetary-computer --quiet
# Search and download Sentinel-2 imagery over London
import pystac_client
import planetary_computer
import requests
from pathlib import Path
from databricks.labs.gbx.rasterx import functions as rx
sample_path = "/Volumes/main/default/geobrix_samples/geobrix-examples"
# Configure
rx.register(spark)
output_dir = Path(f"{sample_path}/london/sentinel2")
output_dir.mkdir(parents=True, exist_ok=True)
# Connect to Microsoft Planetary Computer STAC API
catalog = pystac_client.Client.open(
"https://planetarycomputer.microsoft.com/api/stac/v1",
modifier=planetary_computer.sign_inplace,
)
# Define London bounding box (approximate)
london_bbox = [-0.51, 51.28, 0.33, 51.70] # [west, south, east, north]
# Search for Sentinel-2 scenes
search = catalog.search(
collections=["sentinel-2-l2a"],
bbox=london_bbox,
datetime="2023-06-01/2023-08-31", # Summer for better weather
query={
"eo:cloud_cover": {"lt": 30} # Less than 30% cloud cover (UK has more clouds)
},
limit=10
)
items = list(search.items())
print(f"Found {len(items)} Sentinel-2 scenes over London")
if items:
# Get the least cloudy scene
best_item = min(items, key=lambda x: x.properties.get("eo:cloud_cover", 100))
print(f"Selected scene: {best_item.id}")
print(f" Date: {best_item.datetime}")
print(f" Cloud cover: {best_item.properties.get('eo:cloud_cover')}%")
# Download Red band (B04) - 10m resolution
red_band = best_item.assets["B04"]
red_url = red_band.href
output_file = output_dir / "london_sentinel2_red.tif"
print(f"Downloading Red band (~40MB)...")
response = requests.get(red_url, stream=True)
response.raise_for_status()
with open(output_file, 'wb') as f:
for chunk in response.iter_content(chunk_size=8192):
f.write(chunk)
file_size = output_file.stat().st_size / (1024 * 1024)
print(f"✅ Downloaded Sentinel-2 Red band ({file_size:.1f} MB)")
print(f" Path: {output_file}")
# Verify
raster = spark.read.format("gdal").load(str(output_file))
raster.select(
rx.rst_width("tile").alias("width"),
rx.rst_height("tile").alias("height"),
rx.rst_srid("tile").alias("srid")
).show()
Found 10 Sentinel-2 scenes over London
Selected scene: S2B_MSIL2A_20230722...
Date: 2023-07-22
Cloud cover: 12%