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.

Parameters:
  • lat (float) – Latitude.

  • lon (float) – Longitude.

  • session (Session) – (optional) A requests session.

Returns:

The zoom level, e.g. 20 (≈0.10 m/px) in Seattle, or None if there is no imagery.

Return type:

int | None

async find_max_zoom_async(lat, lon, session)[source]
Parameters:
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.

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:

AerialImage

async get_image_async(north, west, south, east, session, zoom=None, max_tiles=20000, max_concurrency=8)[source]
Parameters:
Return type:

AerialImage

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.xml and .json beside it; 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.

  • 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.save method.

  • 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:

AerialImage

async download_image_async(north, west, south, east, path, session, zoom=None, pil_args=None, max_tiles=20000, max_concurrency=8)[source]
Parameters:
Return type:

AerialImage

get_tile(x, y, zoom, session=None)[source]

Downloads one aerial tile.

Parameters:
  • x (int) – X coordinate of the tile.

  • y (int) – Y coordinate of the tile.

  • zoom (int) – Zoom level.

  • session (Session) – (optional) A requests session.

Returns:

The tile as PIL image, or None if Bing has no imagery for it at this zoom level.

Return type:

Image | None

async get_tile_async(x, y, zoom, session)[source]
Parameters:
  • x (int)

  • y (int)

  • zoom (int)

  • session (ClientSession)

Return type:

Image | None

Creates a Bing Maps link showing aerial imagery at a location.

Parameters:
  • lat (float) – Latitude.

  • lon (float) – Longitude.

  • zoom (int) – (optional) Zoom level. Defaults to 18.

Returns:

A Bing Maps URL.

Return type:

str

to_quadkey(x, y, zoom)[source]

Converts XYZ tile coordinates to a Bing Maps quadkey.

Parameters:
  • x (int) – X coordinate.

  • y (int) – Y coordinate.

  • zoom (int) – Zoom level.

Returns:

The quadkey, which has one digit per zoom level.

Return type:

str

from_quadkey(quadkey)[source]

Converts a Bing Maps quadkey to XYZ tile coordinates.

Parameters:

quadkey (str) – The quadkey.

Returns:

X, Y and zoom.

Google Maps

find_max_zoom(lat, lon, session=None)[source]

Finds the highest zoom level with imagery at a location.

Parameters:
  • lat (float) – Latitude.

  • lon (float) – Longitude.

  • session (Session) – (optional) A requests session.

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

async find_max_zoom_async(lat, lon, session)[source]
Parameters:
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:

AerialImage

async get_image_async(north, west, south, east, session, zoom=None, max_tiles=20000, max_concurrency=8)[source]
Parameters:
Return type:

AerialImage

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.xml and .json beside it; 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.

  • 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.save method.

  • 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:

AerialImage

async download_image_async(north, west, south, east, path, session, zoom=None, pil_args=None, max_tiles=20000, max_concurrency=8)[source]
Parameters:
Return type:

AerialImage

get_tile(x, y, zoom, session=None)[source]

Downloads one aerial tile.

Parameters:
  • x (int) – X coordinate of the tile.

  • y (int) – Y coordinate of the tile.

  • zoom (int) – Zoom level.

  • session (Session) – (optional) A requests session.

Returns:

The tile as PIL image, or None if Google has no imagery for it at this zoom level.

Return type:

Image | None

async get_tile_async(x, y, zoom, session)[source]
Parameters:
  • x (int)

  • y (int)

  • zoom (int)

  • session (ClientSession)

Return type:

Image | None

Creates a Google Maps link showing satellite imagery at a location.

Parameters:
  • lat (float) – Latitude.

  • lon (float) – Longitude.

  • zoom (int) – (optional) Zoom level. Defaults to 18.

Returns:

A Google Maps URL.

Return type:

str

Esri World Imagery

find_max_zoom(lat, lon, session=None)[source]

Finds the highest zoom level with imagery at a location.

Parameters:
  • lat (float) – Latitude.

  • lon (float) – Longitude.

  • session (Session) – (optional) A requests session.

Returns:

The zoom level, e.g. 19 (≈0.20 m/px) in Seattle, or None if there is no imagery.

Return type:

int | None

async find_max_zoom_async(lat, lon, session)[source]
Parameters:
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:

AerialImage

async get_image_async(north, west, south, east, session, zoom=None, max_tiles=20000, max_concurrency=8)[source]
Parameters:
Return type:

AerialImage

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.xml and .json beside it; 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.

  • 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.save method.

  • 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:

AerialImage

async download_image_async(north, west, south, east, path, session, zoom=None, pil_args=None, max_tiles=20000, max_concurrency=8)[source]
Parameters:
Return type:

AerialImage

get_tile(x, y, zoom, session=None)[source]

Downloads one aerial tile.

Parameters:
  • x (int) – X coordinate of the tile.

  • y (int) – Y coordinate of the tile.

  • zoom (int) – Zoom level.

  • session (Session) – (optional) A requests session.

Returns:

The tile as PIL image, or None if Esri has no imagery for it at this zoom level.

Return type:

Image | None

async get_tile_async(x, y, zoom, session)[source]
Parameters:
  • x (int)

  • y (int)

  • zoom (int)

  • session (ClientSession)

Return type:

Image | None

Creates a link to Esri World Imagery Wayback, which shows the current World Imagery and its earlier releases, at a location.

Parameters:
  • lat (float) – Latitude.

  • lon (float) – Longitude.

  • zoom (int) – (optional) Zoom level. Defaults to 18.

Returns:

A Wayback URL.

Return type:

str

USGS The National Map

find_max_zoom(lat, lon, session=None)[source]

Finds the highest zoom level with imagery at a location.

Parameters:
  • lat (float) – Latitude.

  • lon (float) – Longitude.

  • session (Session) – (optional) A requests session.

Returns:

The zoom level, e.g. 16 (≈1.6 m/px) in Seattle, or None if there is no detailed imagery (outside the US only a coarse global background exists).

Return type:

int | None

async find_max_zoom_async(lat, lon, session)[source]
Parameters:
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:

AerialImage

async get_image_async(north, west, south, east, session, zoom=None, max_tiles=20000, max_concurrency=8)[source]
Parameters:
Return type:

AerialImage

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.xml and .json beside it; 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.

  • 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.save method.

  • 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:

AerialImage

async download_image_async(north, west, south, east, path, session, zoom=None, pil_args=None, max_tiles=20000, max_concurrency=8)[source]
Parameters:
Return type:

AerialImage

get_tile(x, y, zoom, session=None)[source]

Downloads one aerial tile.

Parameters:
  • x (int) – X coordinate of the tile.

  • y (int) – Y coordinate of the tile.

  • zoom (int) – Zoom level.

  • session (Session) – (optional) A requests session.

Returns:

The tile as PIL image, or None if USGS has no imagery for it at this zoom level.

Return type:

Image | None

async get_tile_async(x, y, zoom, session)[source]
Parameters:
  • x (int)

  • y (int)

  • zoom (int)

  • session (ClientSession)

Return type:

Image | None

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:

List[WaybackRelease]

async get_releases_async(session)[source]
Parameters:

session (ClientSession)

Return type:

List[WaybackRelease]

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:
  • lat (float) – Latitude.

  • lon (float) – Longitude.

  • zoom (int) – (optional) Zoom level to check. Defaults to 19 (≈0.3 m at the equator).

Returns:

A list of WaybackVersion objects. Capture metadata stays None where Esri’s metadata service does not answer.

Return type:

List[WaybackVersion]

async find_versions_async(lat, lon, session, zoom=19)[source]
Parameters:
Return type:

List[WaybackVersion]

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() or find_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; metadata names the release.

Return type:

AerialImage

async get_image_async(north, west, south, east, session, release=None, zoom=19, max_tiles=20000, max_concurrency=8)[source]
Parameters:
Return type:

AerialImage

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.save method.

  • 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:

AerialImage

async download_image_async(north, west, south, east, path, session, release=None, zoom=19, pil_args=None, max_tiles=20000, max_concurrency=8)[source]
Parameters:
Return type:

AerialImage

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:

List[WaybackVersion]

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.

Parameters:
  • id (int)

  • date (date)

  • title (str)

  • tile_url_template (str)

  • metadata_url (str | None)

id: int

Release number, used in tile URLs. Not chronological; sort by date.

date: date

Publication date of the release.

title: str

Title, e.g. World Imagery (Wayback 2026-10-29).

tile_url_template: str

Tile URL with {level}, {row} and {col} placeholders.

metadata_url: str | None = None

ArcGIS MapServer with the capture metadata of this release.

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.

capture_date: date | None = None

Acquisition date of the imagery, from the release metadata.

resolution: float | None = None

Source resolution in meters.

accuracy: float | None = None

Reported horizontal accuracy in meters.

source: str | None = None

Imagery product name, e.g. Vivid Advanced.

provider: str | None = None

Imagery vendor, e.g. Vantor or a local government.

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/resolution choice.

  • 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:

Raster

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]
Parameters:
Return type:

Raster

download_raster(north, west, south, east, path, **kwargs)[source]

Same as get_raster(), then saves the result (see mirrorworld.raster.Raster.save()).

Parameters:
Returns:

The raster.

Return type:

Raster

list_layers(infrared=False)[source]

Lists the available years and resolutions.

Parameters:

infrared (bool) – (optional) List the colour-infrared layers instead of RGB. Defaults to False.

Returns:

WmsLayer objects; names look like 2024_orthoHR (8 cm) or 2024_ortho25IR (25 cm infrared).

Return type:

List[WmsLayer]

layer_name(year=None, infrared=False, high_resolution=True)[source]

Builds a layer name.

Parameters:
  • year (int | str | None) – (optional) Year, or None for the most recent imagery everywhere (“Actueel”).

  • infrared (bool) – (optional) Colour-infrared instead of RGB. Defaults to False.

  • high_resolution (bool) – (optional) 8 cm (“HR”) instead of 25 cm. Defaults to True.

Returns:

e.g. Actueel_orthoHR or 2023_ortho25IR.

Return type:

str

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, so north/west/south/east can differ from the requested box by less than one pixel.

Parameters:
image: Image

The stitched image.

provider: str

Name of the imagery provider.

zoom: int

Zoom level of the tiles the image was stitched from.

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.

origin_x: float

X coordinate of the top left corner in EPSG:3857 meters.

origin_y: float

Y coordinate of the top left corner in EPSG:3857 meters.

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.

tile_count: int

Number of tiles the image was stitched from.

missing_tiles: List[Tuple[int, int]]

X/Y coordinates of tiles the provider has no imagery for at this zoom level. These areas are black.

metadata: dict

Provider-specific metadata, e.g. capture date ranges reported by Bing.

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, .tfw or .wld) in EPSG:3857 meters, a GDAL .aux.xml sidecar declaring the CRS so that GDAL, rasterio and QGIS place the image correctly, and a .json file 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.

Parameters:
  • lat (float) – Latitude.

  • zoom (int) – Zoom level.

Returns:

Meters per pixel on the ground.

Return type:

float

zoom_for_resolution(lat, meters_per_pixel)[source]

Finds the zoom level whose ground resolution is closest (on a log scale) to the requested one.

Parameters:
  • lat (float) – Latitude.

  • meters_per_pixel (float) – Target ground resolution.

Returns:

The zoom level, e.g. 20 for 0.10 m at 47.6° N.

Return type:

int