GoogleAerialImageExtractor

GoogleAerialImageExtractor#

class rapidtools.data_sources.GoogleAerialImageExtractor(save_directory: str | Path = 'output', zoom_level: int = 20, max_workers: int = 10, layer: str = 's', **kwargs: Any)[source]#

Bases: WebMercatorTileExtractor

Client for extracting satellite imagery from Google Maps tiles.

Parameters:
  • save_directory – Directory where stitched images will be saved.

  • zoom_level – Map detail level (1-21). Defaults to 20 (~0.15 m/px).

  • max_workers – Number of concurrent download threads.

  • layer – 's' for satellite imagery (default) or 'y' for the hybrid layer with road labels.

Example

>>> from rapidtools.data_sources import GoogleAerialImageExtractor
>>> with GoogleAerialImageExtractor('out', zoom_level=20) as extractor:
...     for tile, bbox, (x, y, z) in extractor.generate_polygon_tiles(feature):
...         print(x, y, z, tile.size)

Methods

buffered_bounds

Expand a polygon's bounds by a percentage of its width and height.

generate_polygon_tiles

Yield individual tiles intersecting a GeoJSON polygon feature.

generate_region_tiles

Yield individual tiles covering a bounding box.

lat_lon_to_pixel

Convert latitude and longitude to global Web Mercator pixel coordinates.

pad_to_square

Center an image on a black square canvas whose side is its longer edge.

pixel_to_lat_lon

Convert global Web Mercator pixel coordinates back to latitude/longitude.

process_geojson

Read a GeoJSON file and save one image per polygon feature.

process_polygon

Download, stitch, crop and save imagery for one GeoJSON polygon feature.

stitch_region

Download every tile covering a bounding box and crop the mosaic to it.

tile_bounds

Return the geographic bounds of an XYZ tile.