BingAerialImageExtractor#
- class rapidtools.data_sources.BingAerialImageExtractor(save_directory: str | Path = 'output', zoom_level: int = 20, max_workers: int = 10, **kwargs: Any)[source]#
Bases:
WebMercatorTileExtractorClient for extracting high-resolution imagery from Bing Maps tiles.
Use it as a context manager; tiles are downloaded through a pooled, retrying session. Supports stitching polygons into images and yielding individual tiles for machine-learning pipelines.
Example
>>> from rapidtools.data_sources import BingAerialImageExtractor >>> BingAerialImageExtractor.tile_to_quadkey(3, 5, zoom=3) '213' >>> with BingAerialImageExtractor('out', zoom_level=18) as extractor: ... print(extractor.process_polygon(feature, index=0)) Success: test_building
Methods
buffered_boundsExpand a polygon's bounds by a percentage of its width and height.
generate_polygon_tilesYield individual tiles intersecting a GeoJSON polygon feature.
generate_region_tilesYield individual tiles covering a bounding box.
lat_lon_to_pixelConvert latitude and longitude to global Web Mercator pixel coordinates.
pad_to_squareCenter an image on a black square canvas whose side is its longer edge.
pixel_to_lat_lonConvert global Web Mercator pixel coordinates back to latitude/longitude.
process_geojsonRead a GeoJSON file and save one image per polygon feature.
process_polygonDownload, stitch, crop and save imagery for one GeoJSON polygon feature.
stitch_regionDownload every tile covering a bounding box and crop the mosaic to it.
tile_boundsReturn the geographic bounds of an XYZ tile.
Convert tile XY coordinates into a Bing Maps quadkey string.
- static tile_to_quadkey(tile_x: int, tile_y: int, zoom: int) str[source]#
Convert tile XY coordinates into a Bing Maps quadkey string.
- Parameters:
tile_x – Tile column index.
tile_y – Tile row index.
zoom – Zoom level (equals the length of the returned quadkey).
- Returns:
str – The quadkey used to fetch the tile from Bing’s servers.
Example
>>> BingAerialImageExtractor.tile_to_quadkey(3, 5, zoom=3) '213'