Reference

A Python library and utility to download Google StreetView imagery.

class streetviewdownloader.StreetNetworkPointGenerator

Download a street network and generate a point data set at regular distances.

points_on_street_network(extent, distance_between_points=20)

Interpolate points along all streets within extent at distance_between_points.

Parameters:
  • extent (shapely.geometry.Polygon) – For which area to calculate interpolated points

  • distance_between_points (int | float) – The distance in meters between interpolated points

Returns:

The interpolated points (Point geometry in column geometry, no other columns)

Return type:

GeoDataFrame

property street_network

Street network covering self.extent (read-only).

class streetviewdownloader.StreetViewDownloader(api_key, url_signing_key)

Download StreetView images and metadata.

Parameters:
  • api_key (str) – StreetView Static API api key

  • str (url_signing_key) – StreetView Static API url signing key

download(extent, output_directory, metadata_only=False)

Download all street view images in extent.

Parameters:
  • extent (shapely.geometry.Polygon) – Download images within this extent

  • output_directory (str) – Path to which to save downloaded images and metadata.

  • metadata_only (bool) – Download only metadata, no images (default: False)

Notes

Metadata will be saved as metadata.gpkg (appending to existing files)

Images will be saved to {pano_id:s}_{heading:03d}.jpg in output_directory/${pano_id}[0:1]/${pano_id}[0:2]/. For example, an image for heading 0 (North) for the StreetView panorama with pano_id = "ABCDEF123456ABC" would be saved to output_directory/A/AB/ABCDEF123456ABC_000.jpg.

class streetviewdownloader.StreetViewImageDownloader(api_key, url_signing_key)

Initialise a StreetViewImageDownloader.

Parameters:
  • api_key (str) – StreetView Static API api key

  • str (url_signing_key) – StreetView Static API url signing key

download(metadata, output_directory)

Download images for all panorama IDs listed in metadata.

Parameters:
  • metadata (pandas.DataFrame) – List of StreetView panorama ids to download (in column pano_id, as returned by StreetViewMetadataDownloader.download()

  • output_directory (str) – Path to which to save downloaded images and metadata.

Notes

The images will be saved to {pano_id:s}_{heading:03d}.jpg in output_directory/${pano_id}[0:1]/${pano_id}[0:2]/. For example, an image for heading 0 (North) for the StreetView panorama with pano_id = "ABCDEF123456ABC" would be saved to output_directory/A/AB/ABCDEF123456ABC_000.jpg.

class streetviewdownloader.StreetViewMetadataDownloader(api_key, url_signing_key)

Download metadata from the StreetView Static API.

Parameters:
  • api_key (str) – StreetView Static API api key

  • str (url_signing_key) – StreetView Static API url signing key

download(points)

Download metadata for the closest StreetView panorama to each point.

Parameters:

points (geopandas.GeoDataFrame) – Search for the closest StreetView panorama to each point

Returns:

Date, pano_id and location (Point geometry) of the StreetView panoramas found

Return type:

geopandas.GeoDataFrame

class streetviewdownloader.StreetViewStaticApiAuth(api_key, url_signing_key)

Authenticate a request to StreetView static API.

Adds API key and signs request url, to be used as a requests authentication hook.

Parameters:
  • api_key (str) – StreetView Static API api key

  • str (url_signing_key) – StreetView Static API url signing key

Examples

>>> import requests
...
... API_KEY = "1234567"
... URL_SIGNING_KEY = "abcdefgh"
...
... with requests.get(
...     "https://maps.googleapis.com/maps/api/streetview/metadata"
...     params={"location": "24.9631,60.2052"},
...     auth=StreetViewStaticApiAuth(API_KEY, URL_SIGNING_KEY)
... ) as response:
...     panorama_metadata = response.json()