mirrorworld.aerial: Aerial imagery¶
Orthoimagery from web map tile services, stitched for a bounding box and saved with its georeferencing
(EPSG:3857). Every provider has the same functions; replace bing with google, esri or usgs.
Usage sample:
from mirrorworld.aerial import bing print(bing.find_max_zoom(47.6062, -122.3321)) # 20, i.e. 0.10 m/px aerial = bing.download_image(47.6070, -122.3345, 47.6055, -122.3320, "seattle.jpg", zoom=20) print(aerial.ground_resolution, aerial.metadata)Command line:
python -m mirrorworld.aerial bing 47.6070 -122.3345 47.6055 -122.3320 seattle.jpg --resolution 0.10 python -m mirrorworld.aerial esri 47.6070 -122.3345 47.6055 -122.3320 --max-zoom
Bing Maps¶
- find_max_zoom(lat, lon, session=None)[source]¶
Finds the highest zoom level with imagery at a location.
- get_image(north, west, south, east, zoom=None, max_tiles=20000, max_concurrency=8)[source]¶
Downloads the aerial imagery inside a bounding box and stitches it into one image.
Capture date ranges reported by Bing are collected in
AerialImage.metadata.
- 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.
zoom (int) – (optional) Zoom level. Defaults to the highest one available at the center of the box.
max_tiles (int) – (optional) Refuse requests covering more tiles than this. Defaults to 20000.
max_concurrency (int) – (optional) Maximum number of simultaneous requests. Defaults to 8.
- Returns:
The stitched image.
- Return type:
- async get_image_async(north, west, south, east, session, zoom=None, max_tiles=20000, max_concurrency=8)[source]¶
- download_image(north, west, south, east, path, zoom=None, pil_args=None, max_tiles=20000, max_concurrency=8)[source]¶
Downloads the aerial imagery inside a bounding box to a georeferenced file (world file,
.aux.xmland.jsonbeside it; seemirrorworld.aerial.util.save_aerial_image()).
- 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.
path (str) – Output path.
zoom (int) – (optional) Zoom level. Defaults to the highest one available at the center of the box.
pil_args (dict) – (optional) Additional arguments for PIL’s
Image.savemethod.max_tiles (int) – (optional) Refuse requests covering more tiles than this. Defaults to 20000.
max_concurrency (int) – (optional) Maximum number of simultaneous requests. Defaults to 8.
- Returns:
The stitched image.
- Return type:
- async download_image_async(north, west, south, east, path, session, zoom=None, pil_args=None, max_tiles=20000, max_concurrency=8)[source]¶
- build_permalink(lat, lon, zoom=18)[source]¶
Creates a Bing Maps link showing aerial imagery at a location.
Google Maps¶
- find_max_zoom(lat, lon, session=None)[source]¶
Finds the highest zoom level with imagery at a location.
- Parameters:
- Returns:
The zoom level, or None if there is no imagery. Google serves upsampled tiles beyond the native resolution in some areas, so this is the highest zoom level Google answers, not necessarily the native resolution.
- Return type:
int | None
- get_image(north, west, south, east, zoom=None, max_tiles=20000, max_concurrency=8)[source]¶
Downloads the aerial imagery inside a bounding box and stitches it into one image.
- 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.
zoom (int) – (optional) Zoom level. Defaults to the highest one available at the center of the box.
max_tiles (int) – (optional) Refuse requests covering more tiles than this. Defaults to 20000.
max_concurrency (int) – (optional) Maximum number of simultaneous requests. Defaults to 8.
- Returns:
The stitched image.
- Return type:
- async get_image_async(north, west, south, east, session, zoom=None, max_tiles=20000, max_concurrency=8)[source]¶
- download_image(north, west, south, east, path, zoom=None, pil_args=None, max_tiles=20000, max_concurrency=8)[source]¶
Downloads the aerial imagery inside a bounding box to a georeferenced file (world file,
.aux.xmland.jsonbeside it; seemirrorworld.aerial.util.save_aerial_image()).
- 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.
path (str) – Output path.
zoom (int) – (optional) Zoom level. Defaults to the highest one available at the center of the box.
pil_args (dict) – (optional) Additional arguments for PIL’s
Image.savemethod.max_tiles (int) – (optional) Refuse requests covering more tiles than this. Defaults to 20000.
max_concurrency (int) – (optional) Maximum number of simultaneous requests. Defaults to 8.
- Returns:
The stitched image.
- Return type:
- async download_image_async(north, west, south, east, path, session, zoom=None, pil_args=None, max_tiles=20000, max_concurrency=8)[source]¶
Esri World Imagery¶
- find_max_zoom(lat, lon, session=None)[source]¶
Finds the highest zoom level with imagery at a location.
- get_image(north, west, south, east, zoom=None, max_tiles=20000, max_concurrency=8)[source]¶
Downloads the aerial imagery inside a bounding box and stitches it into one image.
- 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.
zoom (int) – (optional) Zoom level. Defaults to the highest one available at the center of the box.
max_tiles (int) – (optional) Refuse requests covering more tiles than this. Defaults to 20000.
max_concurrency (int) – (optional) Maximum number of simultaneous requests. Defaults to 8.
- Returns:
The stitched image.
- Return type:
- async get_image_async(north, west, south, east, session, zoom=None, max_tiles=20000, max_concurrency=8)[source]¶
- download_image(north, west, south, east, path, zoom=None, pil_args=None, max_tiles=20000, max_concurrency=8)[source]¶
Downloads the aerial imagery inside a bounding box to a georeferenced file (world file,
.aux.xmland.jsonbeside it; seemirrorworld.aerial.util.save_aerial_image()).
- 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.
path (str) – Output path.
zoom (int) – (optional) Zoom level. Defaults to the highest one available at the center of the box.
pil_args (dict) – (optional) Additional arguments for PIL’s
Image.savemethod.max_tiles (int) – (optional) Refuse requests covering more tiles than this. Defaults to 20000.
max_concurrency (int) – (optional) Maximum number of simultaneous requests. Defaults to 8.
- Returns:
The stitched image.
- Return type:
- async download_image_async(north, west, south, east, path, session, zoom=None, pil_args=None, max_tiles=20000, max_concurrency=8)[source]¶
USGS The National Map¶
- find_max_zoom(lat, lon, session=None)[source]¶
Finds the highest zoom level with imagery at a location.
- get_image(north, west, south, east, zoom=None, max_tiles=20000, max_concurrency=8)[source]¶
Downloads the aerial imagery inside a bounding box and stitches it into one image.
- 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.
zoom (int) – (optional) Zoom level. Defaults to the highest one available at the center of the box.
max_tiles (int) – (optional) Refuse requests covering more tiles than this. Defaults to 20000.
max_concurrency (int) – (optional) Maximum number of simultaneous requests. Defaults to 8.
- Returns:
The stitched image.
- Return type:
- async get_image_async(north, west, south, east, session, zoom=None, max_tiles=20000, max_concurrency=8)[source]¶
- download_image(north, west, south, east, path, zoom=None, pil_args=None, max_tiles=20000, max_concurrency=8)[source]¶
Downloads the aerial imagery inside a bounding box to a georeferenced file (world file,
.aux.xmland.jsonbeside it; seemirrorworld.aerial.util.save_aerial_image()).
- 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.
path (str) – Output path.
zoom (int) – (optional) Zoom level. Defaults to the highest one available at the center of the box.
pil_args (dict) – (optional) Additional arguments for PIL’s
Image.savemethod.max_tiles (int) – (optional) Refuse requests covering more tiles than this. Defaults to 20000.
max_concurrency (int) – (optional) Maximum number of simultaneous requests. Defaults to 8.
- Returns:
The stitched image.
- Return type:
- async download_image_async(north, west, south, east, path, session, zoom=None, pil_args=None, max_tiles=20000, max_concurrency=8)[source]¶
Esri World Imagery Wayback¶
Every archived release of Esri World Imagery since 2014, for change detection and multi-temporal work.
find_versions() lists only the releases that changed the imagery at a place, with capture dates.
- get_releases()[source]¶
Lists all archived releases of Esri World Imagery, newest first.
- Returns:
A list of WaybackRelease objects.
- Return type:
- find_versions(lat, lon, zoom=19)[source]¶
Lists the distinct versions of the imagery at a location, newest first, each with its capture date. Releases that re-publish an unchanged capture are merged (see
merge_versions()).
- Parameters:
- Returns:
A list of WaybackVersion objects. Capture metadata stays None where Esri’s metadata service does not answer.
- Return type:
- get_image(north, west, south, east, release=None, zoom=19, max_tiles=20000, max_concurrency=8)[source]¶
Downloads the imagery of one release inside a bounding box and stitches it into one image.
- 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.
release (WaybackRelease | int | None) – (optional) A release from
get_releases()orfind_versions(), or its ID. Defaults to the newest release.zoom (int) – (optional) Zoom level. Defaults to 19.
max_tiles (int) – (optional) Refuse requests covering more tiles than this. Defaults to 20000.
max_concurrency (int) – (optional) Maximum number of simultaneous requests. Defaults to 8.
- Returns:
The stitched image;
metadatanames the release.- Return type:
- async get_image_async(north, west, south, east, session, release=None, zoom=19, max_tiles=20000, max_concurrency=8)[source]¶
- Parameters:
- Return type:
- download_image(north, west, south, east, path, release=None, zoom=19, pil_args=None, max_tiles=20000, max_concurrency=8)[source]¶
Downloads the imagery of one release inside a bounding box to a georeferenced file (see
mirrorworld.aerial.util.save_aerial_image()).
- 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.
path (str) – Output path.
release (WaybackRelease | int | None) – (optional) A release or release ID. Defaults to the newest release.
zoom (int) – (optional) Zoom level. Defaults to 19.
pil_args (dict) – (optional) Additional arguments for PIL’s
Image.savemethod.max_tiles (int) – (optional) Refuse requests covering more tiles than this. Defaults to 20000.
max_concurrency (int) – (optional) Maximum number of simultaneous requests. Defaults to 8.
- Returns:
The stitched image.
- Return type:
- async download_image_async(north, west, south, east, path, session, release=None, zoom=19, pil_args=None, max_tiles=20000, max_concurrency=8)[source]¶
- merge_versions(versions)[source]¶
Merges consecutive versions (newest first) with the same capture date: Esri regularly re-publishes (and sometimes re-processes, changing the reported resolution) an unchanged capture in a new release. Each merged entry keeps the oldest release, i.e. the one that introduced the capture. Versions without capture metadata are never merged.
- Parameters:
versions (List[WaybackVersion])
- Return type:
Usage sample:
from mirrorworld.aerial import wayback versions = wayback.find_versions(47.6062, -122.3321) for v in versions: print(v.release.date, v.capture_date, v.resolution, v.provider) wayback.download_image(47.6068, -122.3340, 47.6058, -122.3325, "2011.jpg", release=versions[-1])
- class WaybackRelease(id, date, title, tile_url_template, metadata_url=None)[source]¶
One archived release of Esri World Imagery.
- class WaybackVersion(release, capture_date=None, resolution=None, accuracy=None, source=None, provider=None)[source]¶
A distinct version of the imagery at one location, i.e. the release that introduced it.
- Parameters:
- release: WaybackRelease¶
The release in which this imagery first appeared.
PDOK (Netherlands)¶
Yearly nationwide Dutch orthophotos in RGB and colour-infrared at 8 cm (5 cm in parts of 2025-2026) and 25 cm.
Returns a mirrorworld.raster.Raster.
- get_raster(north, west, south, east, year=None, infrared=False, resolution=0.08, crs='EPSG:28992', layer=None, max_size=2000, max_concurrency=4)[source]¶
Downloads Dutch orthophotos 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.
year (int | str | None) – (optional) Year, or None for the most recent imagery. Defaults to None.
infrared (bool) – (optional) Colour-infrared (bands: near-infrared, red, green) instead of RGB. Defaults to False.
resolution (float) – (optional) Pixel size in meters. Values below 0.25 use the high-resolution layers, which do not exist for every year (see
list_layers()). Defaults to 0.08.crs (str) – (optional) Output CRS. Defaults to EPSG:28992.
layer (str | None) – (optional) Explicit layer name, overriding
year/infrared/resolutionchoice.max_size (int) – (optional) Largest image side per request. Defaults to 2000.
max_concurrency (int) – (optional) Maximum number of simultaneous requests. Defaults to 4.
- Returns:
The raster.
- Return type:
- async get_raster_async(north, west, south, east, session, year=None, infrared=False, resolution=0.08, crs='EPSG:28992', layer=None, max_size=2000, max_concurrency=4)[source]¶
- download_raster(north, west, south, east, path, **kwargs)[source]¶
Same as
get_raster(), then saves the result (seemirrorworld.raster.Raster.save()).
- layer_name(year=None, infrared=False, high_resolution=True)[source]¶
Builds a layer name.
- Parameters:
- Returns:
e.g.
Actueel_orthoHRor2023_ortho25IR.- Return type:
Usage sample:
from mirrorworld.aerial import pdok pdok.download_raster(52.3736, 4.8915, 52.3728, 4.8932, "dam_2025_cir.png", year=2025, infrared=True)
Data classes and utilities¶
- class AerialImage(image, provider, zoom, north, west, south, east, origin_x, origin_y, mercator_resolution, ground_resolution, tile_count, missing_tiles=<factory>, metadata=<factory>)[source]¶
A stitched aerial image covering a bounding box, with the information needed to georeference it.
The image is in Web Mercator (EPSG:3857). Its edges lie on pixel boundaries of the tile grid at
zoom, sonorth/west/south/eastcan differ from the requested box by less than one pixel.
- Parameters:
- image: Image¶
The stitched image.
- mercator_resolution: float¶
Pixel size in EPSG:3857 meters. Larger than the ground resolution away from the equator.
- ground_resolution: float¶
Approximate pixel size on the ground in meters at the center of the image.
- save_aerial_image(aerial, path, pil_args=None)[source]¶
Saves an aerial image with its georeferencing.
Next to the image, this writes a world file (
.jgw,.pgw,.tfwor.wld) in EPSG:3857 meters, a GDAL.aux.xmlsidecar declaring the CRS so that GDAL, rasterio and QGIS place the image correctly, and a.jsonfile with the remaining metadata.
- Parameters:
aerial (AerialImage) – The image.
path (str) – Output path.
pil_args (dict) – (optional) Additional arguments for PIL’s Image.save method, e.g.
{"quality":100}. Defaults to{"quality": 95}for JPEG and{}otherwise.- Return type:
None
- ground_resolution(lat, zoom)[source]¶
Calculates the ground resolution of a Web Mercator tile pyramid.