mirrorworld.kartaview: KartaView

KartaView (formerly OpenStreetCam) has a public API that needs no key. Imagery is CC BY-SA 4.0. Photos can be 360° panoramas or ordinary dashcam/phone photos (is_equirectangular). Downloads try the original file first and fall back to KartaView’s CDN copy when a storage host fails.

Finding photos

find_panoramas(lat, lon, radius=25, limit=100, session=None)[source]

Finds photos within a radius around a point, closest first.

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

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

  • radius (float) – (optional) Search radius in meters. Defaults to 25.

  • limit (int | None) – (optional) Maximum number of results. Defaults to 100.

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

Returns:

A list of KartaViewPanorama objects.

Return type:

List[KartaViewPanorama]

async find_panoramas_async(lat, lon, session, radius=25, limit=100)[source]
Parameters:
Return type:

List[KartaViewPanorama]

find_panorama_by_id(panoid, session=None)[source]

Fetches metadata of a specific photo.

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

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

Returns:

A KartaViewPanorama object, or None if no photo with this ID exists.

Return type:

KartaViewPanorama | None

async find_panorama_by_id_async(panoid, session)[source]
Parameters:
  • panoid (int)

  • session (ClientSession)

Return type:

KartaViewPanorama | None

get_sequence(sequence_id, session=None)[source]

Fetches all photos of a sequence (track), in capture order.

Parameters:
  • sequence_id (int) – The sequence ID.

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

Returns:

A list of KartaViewPanorama objects.

Return type:

List[KartaViewPanorama]

async get_sequence_async(sequence_id, session)[source]
Parameters:
  • sequence_id (int)

  • session (ClientSession)

Return type:

List[KartaViewPanorama]

Usage sample:

from mirrorworld import kartaview

panos = kartaview.find_panoramas(47.6062, -122.3321, radius=100)
print(panos[0].distance, panos[0].date, panos[0].permalink)
kartaview.download_panorama(panos[0], f"{panos[0].id}.jpg")

Async:

from mirrorworld import kartaview
from aiohttp import ClientSession

async with ClientSession() as session:
    panos = await kartaview.find_panoramas_async(47.6062, -122.3321, session, radius=100)
    await kartaview.download_panorama_async(panos[0], f"{panos[0].id}.jpg", session)

Downloading photos

get_panorama(pano, size='full', session=None)[source]

Downloads a photo and returns it as PIL image.

Parameters:
  • pano (KartaViewPanorama | int) – The photo, or its ID.

  • size (str) – (optional) full, large (large thumbnail) or small (thumbnail). Defaults to full.

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

Returns:

A PIL image.

Return type:

Image

async get_panorama_async(pano, session, size='full')[source]
Parameters:
Return type:

Image

download_panorama(pano, path, size='full', pil_args=None, session=None)[source]

Downloads a photo to a file. If the chosen format is JPEG, Exif metadata (and XMP GPano metadata for 360° panoramas) is included.

Parameters:
  • pano (KartaViewPanorama | int) – The photo, or its ID.

  • path (str) – Output path.

  • size (str) – (optional) full, large or small. Defaults to full.

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

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

Return type:

None

async download_panorama_async(pano, path, session, size='full', pil_args=None)[source]
Parameters:
Return type:

None

Data classes

class KartaViewPanorama(id, lat, lon, date=None, heading=None, sequence_id=None, sequence_index=None, field_of_view=None, projection=None, width=None, height=None, matched_lat=None, matched_lon=None, way_id=None, gps_accuracy=None, distance=None, image_urls=None)[source]

Metadata of a KartaView photo.

KartaView (formerly OpenStreetCam) hosts both 360° panoramas and ordinary dashcam/phone photos; is_equirectangular tells them apart. The class is named like the other providers’ for consistency.

Parameters:
id: int

The photo ID.

lat: float

Latitude as recorded by the device.

lon: float

Longitude as recorded by the device.

date: datetime | None = None

Capture time (device local time as reported by the API).

heading: float | None = None

Heading in radians, where 0 is north and π/2 is east.

sequence_id: int | None = None

ID of the sequence (track) the photo belongs to.

sequence_index: int | None = None

Position of the photo in its sequence.

field_of_view: int | None = None

Horizontal field of view in degrees as reported; 360 for panoramas, often 0 (unknown) otherwise.

projection: str | None = None

Projection: PLANE for ordinary photos, SPHERE for 360° panoramas.

width: int | None = None

Width of the full-size image in pixels.

height: int | None = None

Height of the full-size image in pixels.

matched_lat: float | None = None

Latitude snapped to the matched OSM way.

matched_lon: float | None = None

Longitude snapped to the matched OSM way.

way_id: int | None = None

ID of the OSM way the photo was matched to, if any.

gps_accuracy: float | None = None

Reported GPS accuracy in meters.

distance: float | None = None

Distance from the search point in meters (only set by find_panoramas()).

image_urls: Dict[str, List[str]] | None = None

Candidate URLs by size (full, large, small): the original storage file first, then the CDN copy (same pixel size, re-encoded), which is used when a storage host fails.

A link to this photo on kartaview.org.

Miscellaneous

Creates a link to a photo on kartaview.org.

Parameters:
  • sequence_id (int) – ID of the sequence (track) the photo belongs to.

  • sequence_index (int) – (optional) Position of the photo in the sequence. Defaults to 0.

Returns:

A KartaView URL.

Return type:

str