mirrorworld.satellite: Satellite imagery (STAC)¶
Imagery from STAC catalogues, read from cloud-optimized GeoTIFFs for just the requested box. Searching is
sync and async; reading uses GDAL and is sync only. Needs pip install mirrorworld[raster].
Scenes default to the newest acquisition covering the box; Sentinel-2 and Landsat additionally check the cloud
mask inside the box itself (max_local_cloud).
Generic STAC¶
- search(endpoint, collections, north, west, south, east, start=None, end=None, max_cloud_cover=None, query=None, limit=100, session=None)[source]¶
Searches a STAC API for items intersecting a bounding box, newest first.
- Parameters:
endpoint (str) – STAC API root, e.g.
EARTH_SEARCHorPLANETARY_COMPUTER.north (float) – Latitude of the top edge.
west (float) – Longitude of the left edge.
south (float) – Latitude of the bottom edge.
east (float) – Longitude of the right edge.
start (str | datetime | None) – (optional) Earliest acquisition, e.g.
"2024-06-01".end (str | datetime | None) – (optional) Latest acquisition.
max_cloud_cover (float | None) – (optional) Maximum
eo:cloud_coverin percent.query (dict | None) – (optional) Further STAC query conditions, e.g.
{"sat:orbit_state": {"eq": "ascending"}}.limit (int) – (optional) Maximum number of items. Defaults to 100.
session (Session) – (optional) A requests session.
- Returns:
A list of Scene objects.
- Return type:
- async search_async(endpoint, collections, north, west, south, east, session, start=None, end=None, max_cloud_cover=None, query=None, limit=100)[source]¶
- read(scenes, assets, north, west, south, east, resolution=None, crs=None, resampling='nearest', dtype=None)[source]¶
Reads assets of one or more items for a bounding box onto a common grid.
With several items (e.g. adjacent tiles of one pass, or a time series to composite), the first item with data at a pixel wins, so pass them in order of preference.
- Parameters:
scenes (Scene | Sequence[Scene]) – A Scene or a list of Scenes.
assets (Sequence[str]) – Asset names, e.g.
["red", "green", "blue", "nir"]. Multi-band assets (e.g. NAIP’simage) contribute all their bands.north (float) – Latitude of the top edge.
west (float) – Longitude of the left edge.
south (float) – Latitude of the bottom edge.
east (float) – Longitude of the right edge.
resolution (float | None) – (optional) Pixel size in units of
crs. Defaults to the first asset’s native size.crs (str | None) – (optional) Output CRS. Defaults to the first asset’s native CRS.
resampling (str) – (optional)
nearest,bilinear,cubic,average, … Defaults to nearest.dtype (str | None) – (optional) Output data type. Defaults to the first asset’s.
- Returns:
A Raster with one band per asset band;
metadatalists the item IDs, dates and scale/offset of each band where the catalogue gives them.- Return type:
- pick_scenes(scenes, north, west, south, east)[source]¶
Picks the newest acquisition date that covers the box, returning all items of that date (adjacent tiles of one pass) with the least cloudy first. Falls back to the newest scene.
- pick_clear_scenes(scenes, north, west, south, east, mask_asset, is_cloud, max_fraction, max_checks=15)[source]¶
Picks the newest scene whose cloud mask shows at most
max_fractioncloud inside the box. Scene-level cloud cover says little about a small area, so the mask band is read for the box itself (cheap: one band, a few kilobytes). Falls back to the clearest scene checked.
- Parameters:
mask_asset (str) – Name of the cloud/quality mask asset, e.g.
sclorqa_pixel.is_cloud (Callable[[ndarray], ndarray]) – Function mapping mask values to a boolean cloud array.
max_fraction (float) – Largest acceptable cloudy fraction, 0..1.
max_checks (int) – (optional) Number of candidate scenes to check. Defaults to 15.
north (float)
west (float)
south (float)
east (float)
- Returns:
A list with the chosen scene.
- Return type:
- sign_href(scene, href)[source]¶
Makes an asset URL readable. Items from Microsoft Planetary Computer need a short-lived SAS token, fetched anonymously from its token API and cached per collection; other URLs are returned unchanged.
Usage sample:
from mirrorworld.satellite import stac scenes = stac.search(stac.PLANETARY_COMPUTER, "io-lulc-annual-v02", 47.615, -122.345, 47.600, -122.325) raster = stac.read(scenes[0], ["data"], 47.615, -122.345, 47.600, -122.325)
Sentinel-2 (10 m multispectral)¶
- find_scenes(north, west, south, east, start=None, end=None, max_cloud_cover=20, limit=50)[source]¶
Finds Sentinel-2 scenes intersecting a bounding box, newest first.
- Parameters:
north (float) – Latitude of the top edge.
west (float) – Longitude of the left edge.
south (float) – Latitude of the bottom edge.
east (float) – Longitude of the right edge.
start (str | datetime | None) – (optional) Earliest acquisition date, e.g.
"2024-06-01".end (str | datetime | None) – (optional) Latest acquisition date (inclusive).
max_cloud_cover (float | None) – (optional) Maximum cloud cover in percent. Defaults to 20.
limit (int) – (optional) Maximum number of scenes. Defaults to 50.
- Returns:
A list of Scene objects.
- Return type:
- async find_scenes_async(north, west, south, east, session, start=None, end=None, max_cloud_cover=20, limit=50)[source]¶
- get_raster(north, west, south, east, scenes=None, bands=('red', 'green', 'blue', 'nir'), resolution=10.0, crs=None, start=None, end=None, max_cloud_cover=20, resampling='nearest', max_local_cloud=0.1)[source]¶
Reads Sentinel-2 bands for a bounding box.
- Parameters:
north (float) – Latitude of the top edge.
west (float) – Longitude of the left edge.
south (float) – Latitude of the bottom edge.
east (float) – Longitude of the right edge.
scenes (Scene | Sequence[Scene] | None) – (optional) Scene(s) from
find_scenes(). Defaults to the newest acquisition covering the box withinstart/endand undermax_cloud_cover.bands (Sequence[str]) – (optional) Band names, e.g.
nirandredfor NDVI orsclfor the cloud mask. Defaults to("red", "green", "blue", "nir").resolution (float | None) – (optional) Pixel size in meters. Defaults to 10 (the native resolution of the visible and near-infrared bands).
crs (str | None) – (optional) Output CRS. Defaults to the scene’s native CRS (UTM).
start (str | datetime | None) – (optional) Earliest acquisition date when choosing a scene.
end (str | datetime | None) – (optional) Latest acquisition date when choosing a scene.
max_cloud_cover (float | None) – (optional) Maximum cloud cover in percent. Defaults to 20.
resampling (str) – (optional) Resampling method. Defaults to
nearest.max_local_cloud (float) – (optional) When choosing a scene, the largest cloudy fraction (0..1) allowed inside the box itself, judged from the scene classification classes 3 (cloud shadow), 8-9 (cloud) and 10 (cirrus). Defaults to 0.1.
- Returns:
A Raster;
metadatanames the scenes and any scale/offset per band.- Return type:
- download_raster(north, west, south, east, path, **kwargs)[source]¶
Same as
get_raster(), then saves the result (.tifkeeps all bands and values).Usage sample:
from mirrorworld.satellite import sentinel2 r = sentinel2.get_raster(47.615, -122.345, 47.600, -122.325, bands=("red", "nir"), start="2025-06-01", end="2025-09-30") red, nir = (r.band(b) * 0.0001 - 0.1 for b in ("red", "nir")) # scale/offset from r.metadata["band_info"] ndvi = (nir - red) / (nir + red)
Sentinel-1 (10 m radar)¶
- find_scenes(north, west, south, east, start=None, end=None, limit=50)[source]¶
Finds Sentinel-1 RTC scenes intersecting a bounding box, newest first.
- Parameters:
north (float) – Latitude of the top edge.
west (float) – Longitude of the left edge.
south (float) – Latitude of the bottom edge.
east (float) – Longitude of the right edge.
start (str | datetime | None) – (optional) Earliest acquisition date, e.g.
"2024-06-01".end (str | datetime | None) – (optional) Latest acquisition date (inclusive).
limit (int) – (optional) Maximum number of scenes. Defaults to 50.
- Returns:
A list of Scene objects.
- Return type:
- get_raster(north, west, south, east, scenes=None, bands=('vv', 'vh'), resolution=10.0, crs=None, start=None, end=None, resampling='bilinear')[source]¶
Reads Sentinel-1 backscatter for a bounding box.
- Parameters:
north (float) – Latitude of the top edge.
west (float) – Longitude of the left edge.
south (float) – Latitude of the bottom edge.
east (float) – Longitude of the right edge.
scenes (Scene | Sequence[Scene] | None) – (optional) Scene(s) from
find_scenes(). Defaults to the newest acquisition covering the box withinstart/end.bands (Sequence[str]) – (optional)
vvand/orvh. Defaults to("vv", "vh").resolution (float | None) – (optional) Pixel size in meters. Defaults to 10.
crs (str | None) – (optional) Output CRS. Defaults to the scene’s native CRS (UTM).
start (str | datetime | None) – (optional) Earliest acquisition date when choosing a scene.
end (str | datetime | None) – (optional) Latest acquisition date when choosing a scene.
resampling (str) – (optional) Resampling method. Defaults to
bilinear.- Returns:
A Raster;
metadatanames the scenes and any scale/offset per band.- Return type:
- download_raster(north, west, south, east, path, **kwargs)[source]¶
Same as
get_raster(), then saves the result (.tifkeeps all bands and values).Usage sample:
from mirrorworld.satellite import sentinel1 sentinel1.download_raster(47.615, -122.345, 47.600, -122.325, "s1.tif", start="2025-07-01", end="2025-07-31")
Landsat (30 m multispectral and thermal)¶
- find_scenes(north, west, south, east, start=None, end=None, max_cloud_cover=20, limit=50)[source]¶
Finds Landsat scenes intersecting a bounding box, newest first.
- Parameters:
north (float) – Latitude of the top edge.
west (float) – Longitude of the left edge.
south (float) – Latitude of the bottom edge.
east (float) – Longitude of the right edge.
start (str | datetime | None) – (optional) Earliest acquisition date, e.g.
"2024-06-01".end (str | datetime | None) – (optional) Latest acquisition date (inclusive).
max_cloud_cover (float | None) – (optional) Maximum cloud cover in percent. Defaults to 20.
limit (int) – (optional) Maximum number of scenes. Defaults to 50.
- Returns:
A list of Scene objects.
- Return type:
- async find_scenes_async(north, west, south, east, session, start=None, end=None, max_cloud_cover=20, limit=50)[source]¶
- get_raster(north, west, south, east, scenes=None, bands=('red', 'green', 'blue', 'nir08'), resolution=30.0, crs=None, start=None, end=None, max_cloud_cover=20, resampling='nearest', max_local_cloud=0.1)[source]¶
Reads Landsat bands for a bounding box.
- Parameters:
north (float) – Latitude of the top edge.
west (float) – Longitude of the left edge.
south (float) – Latitude of the bottom edge.
east (float) – Longitude of the right edge.
scenes (Scene | Sequence[Scene] | None) – (optional) Scene(s) from
find_scenes(). Defaults to the newest acquisition covering the box withinstart/endand undermax_cloud_cover.bands (Sequence[str]) – (optional) Band names, e.g.
lwir11for surface temperature. Defaults to("red", "green", "blue", "nir08").resolution (float | None) – (optional) Pixel size in meters. Defaults to 30.
crs (str | None) – (optional) Output CRS. Defaults to the scene’s native CRS (UTM).
start (str | datetime | None) – (optional) Earliest acquisition date when choosing a scene.
end (str | datetime | None) – (optional) Latest acquisition date when choosing a scene.
max_cloud_cover (float | None) – (optional) Maximum cloud cover in percent. Defaults to 20.
resampling (str) – (optional) Resampling method. Defaults to
nearest.max_local_cloud (float) – (optional) When choosing a scene, the largest cloudy fraction (0..1) allowed inside the box itself, judged from the QA_PIXEL bits 1-4 (dilated cloud, cirrus, cloud, cloud shadow). Defaults to 0.1.
- Returns:
A Raster;
metadatanames the scenes and any scale/offset per band.- Return type:
- download_raster(north, west, south, east, path, **kwargs)[source]¶
Same as
get_raster(), then saves the result (.tifkeeps all bands and values).Usage sample:
from mirrorworld.satellite import landsat landsat.download_raster(47.615, -122.345, 47.600, -122.325, "lst.tif", bands=("lwir11",), start="2025-06-01", end="2025-09-30")
NAIP (0.6 m RGB + near-infrared, US)¶
- find_scenes(north, west, south, east, start=None, end=None, limit=50)[source]¶
Finds NAIP tiles intersecting a bounding box, newest first.
- Parameters:
north (float) – Latitude of the top edge.
west (float) – Longitude of the left edge.
south (float) – Latitude of the bottom edge.
east (float) – Longitude of the right edge.
start (str | datetime | None) – (optional) Earliest acquisition date, e.g.
"2024-06-01".end (str | datetime | None) – (optional) Latest acquisition date (inclusive).
limit (int) – (optional) Maximum number of scenes. Defaults to 50.
- Returns:
A list of Scene objects.
- Return type:
- get_raster(north, west, south, east, scenes=None, bands=('image',), resolution=None, crs=None, start=None, end=None, resampling='nearest')[source]¶
Reads NAIP imagery (red, green, blue, nir) for a bounding box.
- Parameters:
north (float) – Latitude of the top edge.
west (float) – Longitude of the left edge.
south (float) – Latitude of the bottom edge.
east (float) – Longitude of the right edge.
scenes (Scene | Sequence[Scene] | None) – (optional) Scene(s) from
find_scenes(). Defaults to the newest acquisition covering the box withinstart/end.bands (Sequence[str]) – (optional) Asset names;
imageholds all four bands. Defaults to("image",).resolution (float | None) – (optional) Pixel size in meters. Defaults to the native resolution (0.6 m for recent years).
crs (str | None) – (optional) Output CRS. Defaults to the scene’s native CRS (UTM, NAD83).
start (str | datetime | None) – (optional) Earliest acquisition date when choosing a scene.
end (str | datetime | None) – (optional) Latest acquisition date when choosing a scene.
resampling (str) – (optional) Resampling method. Defaults to
nearest.- Returns:
A Raster;
metadatanames the scenes and any scale/offset per band.- Return type:
- download_raster(north, west, south, east, path, **kwargs)[source]¶
Same as
get_raster(), then saves the result (.tifkeeps all bands and values).Usage sample:
from mirrorworld.satellite import naip naip.download_raster(47.615, -122.345, 47.600, -122.325, "naip.tif")
ESA WorldCover (10 m land cover)¶
- find_scenes(north, west, south, east, start=None, end=None, limit=50)[source]¶
Finds WorldCover tiles intersecting a bounding box, newest first.
- Parameters:
north (float) – Latitude of the top edge.
west (float) – Longitude of the left edge.
south (float) – Latitude of the bottom edge.
east (float) – Longitude of the right edge.
start (str | datetime | None) – (optional) Earliest acquisition date, e.g.
"2024-06-01".end (str | datetime | None) – (optional) Latest acquisition date (inclusive).
limit (int) – (optional) Maximum number of scenes. Defaults to 50.
- Returns:
A list of Scene objects.
- Return type:
- get_raster(north, west, south, east, scenes=None, bands=('map',), resolution=None, crs=None, start=None, end=None, resampling='nearest')[source]¶
Reads WorldCover land cover classes for a bounding box.
- Parameters:
north (float) – Latitude of the top edge.
west (float) – Longitude of the left edge.
south (float) – Latitude of the bottom edge.
east (float) – Longitude of the right edge.
scenes (Scene | Sequence[Scene] | None) – (optional) Scene(s) from
find_scenes(). Defaults to the newest acquisition covering the box withinstart/end.bands (Sequence[str]) – (optional) Asset names;
mapholds the classes. Defaults to("map",).resolution (float | None) – (optional) Pixel size in meters. Defaults to the native resolution (10 m in degrees, EPSG:4326).
crs (str | None) – (optional) Output CRS. Defaults to the scene’s native CRS (EPSG:4326).
start (str | datetime | None) – (optional) Earliest acquisition date when choosing a scene.
end (str | datetime | None) – (optional) Latest acquisition date when choosing a scene.
resampling (str) – (optional) Resampling method. Defaults to
nearest.- Returns:
A Raster;
metadatanames the scenes and any scale/offset per band.- Return type:
- download_raster(north, west, south, east, path, **kwargs)[source]¶
Same as
get_raster(), then saves the result (.tifkeeps all bands and values).Usage sample:
from mirrorworld.satellite import worldcover r = worldcover.get_raster(47.615, -122.345, 47.600, -122.325) print(worldcover.CLASSES)