environmentaltools.download.GoogleMapDownloader

class environmentaltools.download.GoogleMapDownloader(lat: float, lng: float, zoom: int = 12, layer: str = 'v')[source]

Download and stitch Google Maps tiles into high-resolution images.

This class generates high-resolution Google Maps images by downloading and stitching together multiple map tiles based on geographic coordinates and zoom level.

_lat

Latitude of the location.

Type:

float

_lng

Longitude of the location.

Type:

float

_zoom

Zoom level (0-23, where higher values show more detail).

Type:

int

_layer

Map layer type from GoogleMapsLayers.

Type:

str

Example

>>> downloader = GoogleMapDownloader(
...     lat=40.7128,
...     lng=-74.0060,
...     zoom=15,
...     layer=GoogleMapsLayers.SATELLITE
... )
>>> image = downloader.generate_image(tile_width=3, tile_height=3)
>>> image.save("map.png")
__init__(lat: float, lng: float, zoom: int = 12, layer: str = 'v')[source]

Initialize Google Map Downloader.

Parameters:
  • lat (float) – Latitude of the center location in decimal degrees. Valid range: -90 to 90.

  • lng (float) – Longitude of the center location in decimal degrees. Valid range: -180 to 180.

  • zoom (int, optional) – Zoom level ranging from 0 (world view) to 23 (maximum detail). Defaults to 12.

  • layer (str, optional) – Map layer type. Use GoogleMapsLayers constants. Defaults to GoogleMapsLayers.ROADMAP.

Example

>>> gmd = GoogleMapDownloader(40.7128, -74.0060, zoom=15)

Methods

__init__(lat, lng[, zoom, layer])

Initialize Google Map Downloader.

generate_image([start_x, start_y, ...])

Generate high-resolution image by stitching map tiles together.

get_tile_coordinates()

Calculate tile coordinates from latitude, longitude, and zoom level.