streetlevel.yandex: Yandex Panorama

Finding panoramas

find_panorama(lat, lon, session=None)

Searches for a panorama near the given point.

Aerial panoramas are ignored by this API call.

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

  • lon (float) – Longitude of the point.

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

Returns:

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

Return type:

YandexPanorama | None

Usage sample:

from streetlevel import yandex

pano = yandex.find_panorama(43.249064, 76.941999)
print(pano.lat, pano.lon)
print(pano.id)
print(pano.date)
async find_panorama_async(lat, lon, session)
Parameters:
  • lat (float)

  • lon (float)

  • session (ClientSession)

Return type:

YandexPanorama | None

Usage sample:

from streetlevel import yandex
from aiohttp import ClientSession

async with ClientSession() as session:
    pano = await yandex.find_panorama_async(43.249064, 76.941999, session)
    print(pano.lat, pano.lon)
    print(pano.id)
    print(pano.date)
find_panorama_by_id(panoid, session=None)

Fetches metadata of a specific panorama.

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

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

Returns:

A YandexPanorama object if a panorama with this ID exists, or None.

Return type:

YandexPanorama | None

Usage sample:

from streetlevel import yandex

pano = yandex.find_panorama_by_id("1532719828_788624743_23_1678861237")
print(pano.lat, pano.lon)
print(pano.date)
print(pano.heading)
async find_panorama_by_id_async(panoid, session)
Parameters:
  • panoid (str)

  • session (ClientSession)

Return type:

YandexPanorama | None

Usage sample:

from streetlevel import yandex
from aiohttp import ClientSession

async with ClientSession() as session:
    pano = await yandex.find_panorama_by_id_async("1532719828_788624743_23_1678861237", session)
    print(pano.lat, pano.lon)
    print(pano.date)
    print(pano.heading)

Downloading panoramas

get_panorama(pano, zoom=0)

Downloads a panorama and returns it as PIL image.

Note that most official car coverage has its bottom part cropped out.

Parameters:
  • pano (YandexPanorama) – The panorama to download.

  • zoom (int) – (optional) Image size; 0 is highest, 4 is lowest. The dimensions of a zoom level of a specific panorama depend on the camera used. If the requested zoom level does not exist, the highest available level will be downloaded. Defaults to 0.

Returns:

A PIL image containing the panorama.

Return type:

Image

async get_panorama_async(pano, session, zoom=0)
Parameters:
Return type:

Image

download_panorama(pano, path, zoom=0, pil_args=None)

Downloads a panorama to a file. If the chosen format is JPEG, Exif and XMP GPano metadata are included.

Note that most official car coverage has its bottom part cropped out.

Parameters:
  • pano (YandexPanorama) – The panorama to download.

  • path (str) – Output path.

  • zoom (int) – (optional) Image size; 0 is highest, 4 is lowest. The dimensions of a zoom level of a specific panorama depend on the camera used. If the requested zoom level does not exist, the highest available level will be downloaded. Defaults to 0.

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

Return type:

None

Usage sample:

from streetlevel import yandex

pano = yandex.find_panorama_by_id("1532719828_788624743_23_1678861237")
yandex.download_panorama(pano, f"{pano.id}.jpg")
async download_panorama_async(pano, path, session, zoom=0, pil_args=None)
Parameters:
  • pano (YandexPanorama)

  • path (str)

  • session (ClientSession)

  • zoom (int)

  • pil_args (dict | None)

Return type:

None

Usage sample:

from streetlevel import yandex
from aiohttp import ClientSession

async with ClientSession() as session:
    pano = await yandex.find_panorama_by_id_async("1532719828_788624743_23_1678861237", session)
    await yandex.download_panorama_async(pano, f"{pano.id}.jpg", session)

Data classes

class Address(lat, lon, house_number, street_name_and_house_number)

An address whose marker is overlaid on the panorama.

Parameters:
  • lat (float)

  • lon (float)

  • house_number (str)

  • street_name_and_house_number (str)

house_number: str

House number of the address.

lat: float

Latitude of the address.

lon: float

Longitude of the address.

street_name_and_house_number: str

Street name and house number of the address.

class Marker(lat, lon, name, description, style)

A marker which is neither an address, company, nor landmark.

Parameters:
  • lat (float)

  • lon (float)

  • name (str)

  • description (str)

  • style (str)

description: str
lat: float

Latitude of the marker.

lon: float

Longitude of the marker.

name: str
style: str

A link to an element in an XML document describing how the marker should be drawn. What the marker represents can be inferred from the ID of the element.

class Place(id, lat, lon, name, tags)

A company or landmark whose marker is overlaid on the panorama.

Parameters:
  • id (int)

  • lat (float)

  • lon (float)

  • name (str)

  • tags (List[str])

id: int

ID of the place.

lat: float

Latitude of the place’s location.

lon: float

Longitude of the place’s location.

name: str

Name of the place.

tags: List[str]

Typically has one entry specifying the type of the place.

class YandexPanorama(id, lat, lon, heading=None, image_id=None, tile_size=None, image_sizes=None, neighbors=None, links=None, historical=None, date=None, height=None, street_name=None, places=None, addresses=None, other_markers=None, author=None, author_avatar_url=None)

Metadata of a Yandex panorama.

ID, latitude and longitude are always present. The availability of other metadata depends on which function was called and what was returned by the API.

Parameters:
  • id (str)

  • lat (float)

  • lon (float)

  • heading (float)

  • image_id (str)

  • tile_size (Size)

  • image_sizes (List[Size])

  • neighbors (List[YandexPanorama])

  • links (List[Link])

  • historical (List[YandexPanorama])

  • date (datetime)

  • height (float)

  • street_name (str)

  • places (List[Place])

  • addresses (List[Address])

  • other_markers (List[Marker])

  • author (str)

  • author_avatar_url (str)

addresses: List[Address] = None

Addresses whose markers are overlaid on this panorama.

author: str = None

Name of the uploader; only set for third-party panoramas.

author_avatar_url: str = None

URL of the uploader’s avatar; only set for third-party panoramas. Replace %s with small (25x25), normal (100x100) or big (500x500) to get the respective size.

date: datetime = None

Capture date and time of the panorama.

heading: float = None

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

height: float = None

Height above ground (not sea level) in meters.

historical: List[YandexPanorama] = None

A list of panoramas with a different date at the same location.

id: str

The pano ID.

image_id: str = None

Part of the panorama tile URL.

image_sizes: List[Size] = None

The image sizes in which this panorama can be downloaded, from highest to lowest. Indices correspond to zoom levels.

lat: float

Latitude of the panorama’s location.

The panoramas which the white arrows in the client link to.

lon: float

Longitude of the panorama’s location.

neighbors: List[YandexPanorama] = None

A list of nearby panoramas.

other_markers: List[Marker] = None

Represents other markers which are neither an address, company, nor landmark.

Creates a permalink to this panorama.

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.

  • self (YandexPanorama)

Returns:

A Yandex Maps URL which will open this panorama.

Return type:

str

places: List[Place] = None

Companies or landmarks whose markers are overlaid on this panorama.

street_name: str = None

The name of the street the panorama is located on.

tile_size: Size = None

Yandex panoramas are broken up into a grid of tiles. This returns the size of one tile.

Miscellaneous

Creates a permalink to the given panorama. All parameters are optional, but either a location, or a pano ID, or both must be passed.

Parameters:
  • id (str | None) – (optional) The pano ID.

  • lat (float | None) – (optional) Latitude of the panorama’s location.

  • lon (float | None) – (optional) Longitude of the panorama’s location.

  • 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 Yandex Maps URL which will open the given panorama.

Return type:

str