streetlevel

repository·master·Indexed 42 days ago

https://github.com/sk-zk/streetlevel

A Python library for downloading panoramas and metadata from street-level imagery services including Google Street View, Apple Look Around, Yandex Panorama, Bing Streetside, Baidu Panorama, Kakao Road View, Naver Street View, Mapy.cz, and Já 360. It provides a high-level abstraction that works without official API keys and supports both synchronous and asynchronous workflows via aiohttp.

Tokens
13.5K
Snippets
59
Records
77
Agent score
53%

What's inside streetlevel

  1. Overview of streetlevel

    master

    streetlevel is a Python library designed to download panoramas and metadata from various street-level imagery providers by interfacing with their internal APIs.

    Key Coordinate Standards:

    • The library uses latitude/longitude order.
    • All coordinates are in the WGS84 coordinate system unless explicitly stated otherwise in provider-specific documentation.
  2. Overview of supported street-level imagery services

    master

    The streetlevel library provides a unified abstraction over several imagery services. Note that because the library interacts with internal APIs without requiring API keys, it may break if the service providers change their internal structures.

    Supported Services and Capabilities

    ServiceFinding PanoramasImagery TypeImage FormatMetadata (Date, Heading, etc.)
    Google Street ViewAround point, Tile/BBox, by IDPanoramas (Equirectangular)JPEGCapture date, Heading/Pitch/Roll, Elevation, Nearby, Historical, Address, PoIs, Creator
    Apple Look AroundTile/BBox, by IDPanoramas (Equirectangular)HEICCapture date, Heading/Pitch/Roll, Elevation
    Yandex PanoramaAround point, by IDPanoramas (Equirectangular)JPEGCapture date, Heading, Nearby, Historical, Address, PoIs, Creator
    Bing StreetsideAround point, by IDPanoramas (Cubemap)JPEGCapture date, Heading, Elevation, Nearby
    Baidu PanoramaAround point, by IDPanoramas (Equirectangular)JPEGCapture date, Heading, Nearby, Historical, Address
    Kakao Road ViewAround point, by IDPanoramas (Equirectangular/Cubemap)JPEGCapture date, Heading, Nearby, Historical, Address
    Naver Street ViewAround point, by IDPanoramas (Equirectangular)JPEGCapture date, Heading, Nearby, Historical, Address
    Mapy.cz PanoramaAround point, by IDPanoramas (Cubemap)JPEGCapture date, Heading, Address
    Já 360Around point, by IDPanoramas (Cubemap)JPEGCapture date, Heading, Creator

    Notes on capabilities:

    • Finding by point: Returns the closest panorama only.
    • Finding by tile: Uses tile z=17.
    • Finding by BBox: Uses a bounding box.
    • Google Depth: Appears to be a synthetic depth map created from elevation data and building footprints.
    • Naver Imagery: Can be Equirectangular or Cubemap.
    • Apple/Naver/Mapy.cz: Metadata availability varies (e.g., Apple does not provide Address or PoIs).
  3. Data classes for streetlevel.ja panoramas

    master

    The streetlevel.ja module uses specific data classes to represent panorama information:

    • JaPanorama: The primary object representing a panorama, containing metadata like ID, coordinates, and heading.
    • Address: Contains address-related information for the panorama location.
    • CaptureDate: Contains the date information for when the panorama was captured.
  4. Reproject Look Around faces to equirectangular

    master

    Because Look Around provides six separate faces, you may want to stitch them into a single equirectangular image. The to_equirectangular function can perform this reprojection.

    Note: The library does not automatically convert HEIC files to a standard image format. You must convert the HEIC faces (e.g., to PIL images) before passing them to to_equirectangular.

    from streetlevel import lookaround
    
    tile = lookaround.get_coverage_tile_by_latlon(54.583244, 9.820249)
    pano = next(p for p in tile.panos if p.id == 6651337760361848285)
    auth = lookaround.Authenticator()
    faces = []
    zoom = 2
    
    for face_idx in range(0, 6):
        face_heic = lookaround.get_panorama_face(pano, face_idx, zoom, auth)
        # USER STEP: Convert the HEIC file to a PIL image here
        # (e.g., using pillow-heif or similar)
        faces.append(face_heic)
    
    result = lookaround.to_equirectangular(faces, pano.camera_metadata)
    result.save(f"{pano.id}_{zoom}.jpg", options={"quality": 100})
  5. Install streetlevel

    master

    You can install streetlevel via PyPI using pip.

    macOS Users: You may need to install additional system dependencies using Homebrew to ensure all features work correctly:

    brew install gettext
    brew install inih
    pip install streetlevel
  6. Download Google Street View panoramas (Sync)

    master

    To download the closest Google Street View panorama to a specific latitude and longitude using synchronous calls, use streetview.find_panorama followed by streetview.download_panorama.

    This method uses requests internally.

    from streetlevel import streetview
    
    # Find the closest panorama to the coordinates
    pano = streetview.find_panorama(46.883958, 12.169002)
    
    # Download the panorama to a file named after its ID
    streetview.download_panorama(pano, f"{pano.id}.jpg")
  7. Download Google Street View panoramas (Async)

    master

    For asynchronous workflows, use the _async variants of the functions. These require an aiohttp.ClientSession to be passed as an argument.

    This method uses aiohttp internally.

    from streetlevel import streetview
    from aiohttp import ClientSession
    
    async with ClientSession() as session:
        # Find the closest panorama asynchronously
        pano = await streetview.find_panorama_async(46.883958, 12.169002, session)
        
        # Download the panorama asynchronously
        await streetview.download_panorama_async(pano, f"{pano.id}.jpg", session)
  8. Find Apple Look Around panoramas

    master

    You can find available panoramas in a specific area using tile coordinates or latitude/longitude. The library provides both synchronous and asynchronous methods for these lookups. The returned CoverageTile object contains a list of LookaroundPanorama objects.

    from streetlevel import lookaround
    
    # By tile coordinates
    tile = lookaround.get_coverage_tile(109775, 56716)
    
    # By latitude and longitude
    tile = lookaround.get_coverage_tile_by_latlon(23.53239040648735, 121.5068719584602)
    
    first = tile.panos[0]
    print(f"ID: {first.id}\tLatitude: {first.lat}\tLongitude: {first.lon}")
  9. Find Kakao panoramas by coordinates

    master

    Use find_panoramas to search for available Kakao Road View panoramas near a specific latitude and longitude. For asynchronous workflows, use find_panoramas_async which requires an aiohttp.ClientSession.

    from streetlevel import kakao
    
    # Synchronous
    panos = kakao.find_panoramas(37.4481486, 126.4509719)
    print(panos[0].lat, panos[0].lon)
    print(panos[0].id)
    print(panos[0].date)
    
    # Asynchronous
    from aiohttp import ClientSession
    
    async with ClientSession() as session:
        panos = await kakao.find_panoramas_async(37.4481486, 126.4509719, session)
        print(panos[0].lat, panos[0].lon)
        print(panos[0].id)
        print(panos[0].date)
  10. Find Yandex panoramas by coordinates

    master

    Use find_panorama to locate a Yandex panorama near specific latitude and longitude coordinates. For asynchronous workflows, use find_panorama_async which requires an aiohttp.ClientSession.

    from streetlevel import yandex
    
    # Synchronous
    pano = yandex.find_panorama(43.249064, 76.941999)
    print(pano.lat, pano.lon)
    print(pano.id)
    print(pano.date)
    
    # Asynchronous
    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)
  11. Find Google Street View panoramas by ID

    master

    If you already have a panorama ID, you can retrieve the panorama object directly using find_panorama_by_id (synchronous) or find_panorama_by_id_async (asynchronous). The asynchronous version requires an aiohttp.ClientSession.

    from streetlevel import streetview
    from aiohttp import ClientSession
    
    # Synchronous
    # Note: find_panorama_by_id is documented as async in the source, use await if applicable
    pano = await streetview.find_panorama_by_id("Py5vaKsLWJG16XyZosdYBQ")
    
    # Asynchronous
    async with ClientSession() as session:
        pano = await streetview.find_panorama_by_id_async("Py5vaKsLWJG16XyZosdYBQ", session)
        print(pano.id)
  12. Download Yandex panorama images

    master

    Once you have a YandexPanorama object, you can download the image to a file. Use download_panorama for synchronous operations or download_panorama_async for asynchronous operations (which requires an aiohttp.ClientSession).

    from streetlevel import yandex
    from aiohttp import ClientSession
    
    # Synchronous download
    pano = yandex.find_panorama_by_id("1532719828_788624743_23_1678861237")
    yandex.download_panorama(pano, f"{pano.id}.jpg")
    
    # Asynchronous download
    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)