streetlevel.streetside: Bing Streetside

Finding panoramas

find_panoramas(lat, lon, radius=25, limit=50, session=None)

Retrieves panoramas within a square around a point.

Parameters:
  • lat (float) – Latitude of the center point.

  • lon (float) – Longitude of the center point.

  • radius (float) – (optional) Radius of the square in meters. (Not sure if that’s the correct mathematical term, but you get the idea.) Defaults to 25.

  • limit (int) – (optional) Maximum number of results to return. Defaults to 50.

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

Returns:

A list of StreetsidePanorama objects.

Return type:

List[StreetsidePanorama]

async find_panoramas_async(lat, lon, session, radius=25, limit=50)
Parameters:
  • lat (float) –

  • lon (float) –

  • session (ClientSession) –

  • radius (float) –

  • limit (int) –

Return type:

List[StreetsidePanorama]

find_panoramas_in_bbox(north, west, south, east, limit=50, session=None)

Retrieves panoramas within a bounding box.

Parameters:
  • north (float) – lat1.

  • west (float) – lon1.

  • south (float) – lat2.

  • east (float) – lon2.

  • limit (int) – (optional) Maximum number of results to return. Defaults to 50.

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

Returns:

A list of StreetsidePanorama objects.

Return type:

List[StreetsidePanorama]

async find_panoramas_in_bbox_async(north, west, south, east, session, limit=50)
Parameters:
  • north (float) –

  • west (float) –

  • south (float) –

  • east (float) –

  • session (ClientSession) –

  • limit (int) –

Return type:

List[StreetsidePanorama]

find_panorama_by_id(panoid, session=None)

Fetches metadata for a specific panorama.

Parameters:
  • panoid (int) – The pano ID.

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

Returns:

A StreetsidePanorama object if a panorama was found, or None.

Return type:

StreetsidePanorama | None

async find_panorama_by_id_async(panoid, session)
Parameters:
  • panoid (int) –

  • session (ClientSession) –

Return type:

StreetsidePanorama | None

Downloading panoramas

get_panorama(pano, zoom=4, stitching_method=CubemapStitchingMethod.ROW)

Downloads a panorama and returns it as PIL image.

Parameters:
  • pano (StreetsidePanorama) – The panorama.

  • zoom (int) – (optional) Image size; 0 is lowest, 4 is highest. Defaults to 4. If 4 is not available, 3 will be downloaded. (Note that only the old Microsoft panoramas go up to 4; the TomTom-provided panoramas stop at 3.)

  • stitching_method (CubemapStitchingMethod) – (optional) Whether and how the faces of the cubemap are stitched into one image. Defaults to ROW.

Returns:

A PIL image or a list of six PIL images depending on stitching_method.

Return type:

List[Image] | Image

async get_panorama_async(pano, session, zoom=4, stitching_method=CubemapStitchingMethod.ROW)
Parameters:
Return type:

List[Image] | Image

download_panorama(pano, path, zoom=4, stitching_method=CubemapStitchingMethod.ROW, pil_args=None)

Downloads a panorama to a file.

Parameters:
  • pano (StreetsidePanorama) – The panorama.

  • path (str) – Output path.

  • zoom (int) – (optional) Image size; 0 is lowest, 4 is highest. Defaults to 4. If 4 is not available, 3 will be downloaded. (Note that only the old Microsoft panoramas go up to 4; the TomTom-provided panoramas stop at 3.)

  • stitching_method (CubemapStitchingMethod) – (optional) Whether and how the faces of the cubemap are stitched into one image. Defaults to ROW.

  • pil_args (dict | None) – (optional) Additional arguments for PIL’s Image.save method, e.g. {"quality":100}. Defaults to {}.

Return type:

None

async download_panorama_async(pano, path, session, zoom=4, stitching_method=CubemapStitchingMethod.ROW, pil_args=None)
Parameters:
Return type:

None

Data classes

class StreetsidePanorama(id, lat, lon, date, next=None, previous=None, elevation=None, heading=None, pitch=None, roll=None, max_zoom=None)

Metadata of a Streetside panorama.

Parameters:
  • id (int) –

  • lat (float) –

  • lon (float) –

  • date (datetime) –

  • next (int) –

  • previous (int) –

  • elevation (int) –

  • heading (float) –

  • pitch (float) –

  • roll (float) –

  • max_zoom (int) –

date: datetime

Capture date and time of the panorama.

elevation: int = None

Elevation at the capture location in meters.

heading: float = None

Heading in radians, where 0° is north, 90° is east, 180° is south and 270° is west.

id: int

The pano ID.

lat: float

Latitude of the panorama’s location.

lon: float

Longitude of the panorama’s location.

max_zoom: int = None

Highest zoom level available; 4 for the original Microsoft panoramas, 3 for the TomTom-provided ones.

next: int = None

ID of the next image in the sequence.

Creates a permalink to a panorama at this location. (If a URL for opening a panorama by ID exists, I’ve yet to find it.)

Parameters:
  • heading (float) – (optional) Initial heading of the viewport. Defaults to 0°.

  • pitch (float) – (optional) Initial pitch of the viewport. Defaults to 0°.

  • map_zoom (float) – (optional) Initial zoom level of the map. Defaults to 17.

  • radians (bool) – (optional) Whether angles are in radians. Defaults to False.

Returns:

A Bing Maps URL.

Return type:

str

pitch: float = None

Pitch offset for upright correction of the panorama, in radians.

previous: int = None

ID of the previous image in the sequence.

roll: float = None

Roll offset for upright correction of the panorama, in radians.

Miscellaneous

from_base4(n)

Converts a string containing a base 4 number to integer.

Parameters:

n (str) – The string containing a base 4 number.

Returns:

The integer represented by the string.

Return type:

int

to_base4(n)

Converts an integer to a base 4 string.

Parameters:

n (int) – The integer.

Returns:

The base 4 representation of the integer.

Return type:

str