mirrorworld.naver: Naver Street View¶
Finding panoramas¶
- find_panorama(lat, lon, neighbors=True, historical=True, depth=False, session=None)[source]¶
Searches for a panorama near the given point.
Aerial and underwater panoramas are ignored by this API call.
- Parameters:
lat (float) – Latitude of the point.
lon (float) – Longitude of the point.
neighbors (bool) – (optional) Whether an additional network request is made to fetch nearby panoramas. Defaults to True.
historical (bool) – (optional) Whether an additional network request is made to fetch metadata of historical panoramas. Defaults to True.
depth (bool) – (optional) Whether an additional network request is made to fetch the depth map. Defaults to False.
session (Session) – (optional) A requests session.
- Returns:
A NaverPanorama object if a panorama was found, or None.
- Return type:
NaverPanorama | None
Usage sample:
from mirrorworld import naver pano = naver.find_panorama(37.4481486, 126.4509719) print(pano.lat, pano.lon) print(pano.id) print(pano.date)Usage sample:
from mirrorworld import naver from aiohttp import ClientSession async with ClientSession() as session: pano = await naver.find_panorama_async(37.4481486, 126.4509719, session) print(pano.lat, pano.lon) print(pano.id) print(pano.date)
- find_panorama_by_id(panoid, language='en', neighbors=True, historical=True, depth=False, session=None)[source]¶
Fetches metadata of a specific panorama.
Note that
panorama_type,pitchandrollwill be wrong if this is a 3D panorama because Naver has yet to update this endpoint.
- Parameters:
panoid (str) – The pano ID.
language (str) – (optional) Language of
descriptionandtitlefields; accepted values areko(Korean),en(English),ja(Japanese) andzh(Simplified Chinese).neighbors (bool) – (optional) Whether an additional network request is made to fetch nearby panoramas. Defaults to True.
historical (bool) – (optional) Whether an additional network request is made to fetch metadata of historical panoramas. Defaults to True.
depth (bool) – (optional) Whether an additional network request is made to fetch the depth map. Defaults to False.
session (Session) – (optional) A requests session.
- Returns:
A NaverPanorama object if a panorama with this ID exists, or None.
- Return type:
NaverPanorama | None
Usage sample:
from mirrorworld import naver pano = naver.find_panorama_by_id("hQ46n55JstD9C-tGdzZz2g") print(pano.lat, pano.lon) print(pano.date) print(pano.heading)
- async find_panorama_by_id_async(panoid, session, language='en', neighbors=True, historical=True, depth=False)[source]¶
Usage sample:
from mirrorworld import naver from aiohttp import ClientSession async with ClientSession() as session: pano = await naver.find_panorama_by_id_async("hQ46n55JstD9C-tGdzZz2g", session) print(pano.lat, pano.lon) print(pano.date) print(pano.heading)
- get_depth(panoid, has_equirect, session=None)[source]¶
Fetches the legacy depth map of a panorama.
- Parameters:
- Returns:
The depth map of the faces in the order front, right, back, left, top, bottom.
- Return type:
ndarray
- get_historical(panoid, session=None)[source]¶
Fetches older panoramas at the location of the given panorama.
- Parameters:
panoid (str) – The pano ID. For reasons unbeknownst to mankind, only panoramas older than the given one are returned, so to retrieve all available dates at a location, the ID of the most recent panorama must be used. This is the
timeline_idreturned byfind_panorama_by_id.session (Session) – (optional) A requests session.
- Returns:
A list of NaverPanorama objects.
- Return type:
- async get_historical_async(panoid, session)[source]¶
- Parameters:
panoid (str)
session (ClientSession)
- Return type:
Downloading panoramas¶
- get_panorama(pano, zoom=2, equirect=False, stitching_method=CubemapStitchingMethod.ROW)[source]¶
Downloads a panorama and returns it as PIL image.
- Parameters:
pano (NaverPanorama) – The panorama.
zoom (int) – (optional) Image size; 0 is lowest, 2 is highest. Defaults to 2. If 2 is unavailable, 1 will be downloaded instead.
equirect – (optional) Whether the panorama should be downloaded in equirectangular projection instead of a cubemap. Only available for 3D imagery. Defaults to False.
stitching_method (CubemapStitchingMethod) – (optional) Whether and how the faces of the cubemap are stitched into one image when downloading as cubemap. Defaults to
ROW.- Returns:
A PIL image or a list of six PIL images depending on
equirectandstitching_method.- Return type:
List[Image] | Image
- async get_panorama_async(pano, session, zoom=2, equirect=False, stitching_method=CubemapStitchingMethod.ROW)[source]¶
- Parameters:
pano (NaverPanorama)
session (ClientSession)
zoom (int)
stitching_method (CubemapStitchingMethod)
- Return type:
List[Image] | Image
- download_panorama(pano, path, zoom=2, equirect=False, stitching_method=CubemapStitchingMethod.ROW, pil_args=None)[source]¶
Downloads a panorama to a file. If the chosen format is JPEG, Exif and XMP GPano metadata are included.
- Parameters:
pano (NaverPanorama) – The panorama.
path (str) – Output path.
zoom (int) – (optional) Image size; 0 is lowest, 2 is highest. Defaults to 2. If 2 is unavailable, 1 will be downloaded instead.
equirect – (optional) Whether the panorama should be downloaded in equirectangular projection instead of a cubemap. Only available for 3D imagery. Defaults to False.
stitching_method (CubemapStitchingMethod) – (optional) Whether and how the faces of the cubemap are stitched into one image when downloading as cubemap. Defaults to
ROW.pil_args (dict) – (optional) Additional arguments for PIL’s Image.save method, e.g.
{"quality":100}. Defaults to{}.- Return type:
None
Usage sample:
from mirrorworld import naver pano = naver.find_panorama_by_id("hQ46n55JstD9C-tGdzZz2g") naver.download_panorama(pano, f"{pano.id}.jpg")
- async download_panorama_async(pano, path, session, zoom=2, equirect=False, stitching_method=CubemapStitchingMethod.ROW, pil_args=None)[source]¶
- Parameters:
pano (NaverPanorama)
path (str)
session (ClientSession)
zoom (int)
stitching_method (CubemapStitchingMethod)
pil_args (dict)
- Return type:
None
Usage sample:
from mirrorworld import naver from aiohttp import ClientSession async with ClientSession() as session: pano = await naver.find_panorama_by_id_async("hQ46n55JstD9C-tGdzZz2g", session) await naver.download_panorama_async(pano, f"{pano.id}.jpg", session)
Data classes and Enums¶
- class Model(vertices, faces)[source]¶
The vertices and faces of a 3D model used for 3D panoramas in Naver Map.
(The UV map is not provided by the server, and I haven’t been able to fully work out how to generate it, so it’s not available yet. Sorry.)
- Parameters:
vertices (ndarray)
faces (ndarray)
- vertices: ndarray¶
- faces: ndarray¶
- class NaverPanorama(id, lat, lon, heading=None, altitude=None, pitch=None, roll=None, max_zoom=None, neighbors=None, links=None, historical=None, timeline_id=None, date=None, is_latest=None, description=None, title=None, depth=None, has_equirect=None, panorama_type=None, overlay=None)[source]¶
Metadata of a Naver Street View 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)
altitude (float)
pitch (float)
roll (float)
max_zoom (int)
neighbors (Neighbors)
historical (List[NaverPanorama])
timeline_id (str)
date (datetime)
is_latest (bool)
description (str)
title (str)
depth (ndarray)
has_equirect (bool)
panorama_type (PanoramaType)
overlay (Overlay | None)
- heading: float = None¶
Heading in radians, where 0° is north, 90° is east, 180° is south and 270° is west.
- pitch: float = None¶
Pitch offset for upright correction of the panorama, in radians. Only available if
has_equirectis True; the field is set to 0 otherwise.
- roll: float = None¶
Roll offset for upright correction of the panorama, in radians. Only available if
has_equirectis True; the field is set to 0 otherwise.
- links: List[Link] = None¶
The panoramas which the white dots in the pre-3D client link to. This appears to be unused in the new client.
- historical: List[NaverPanorama] = None¶
A list of panoramas with a different date at the same location. Only available if the panorama was retrieved by
find_panorama_by_id.
- timeline_id: str = None¶
The pano ID that must be given to the API to retrieve the full list of historical panoramas, which is also the ID of the most recent panorama at this location. If an earlier ID is used, only panoramas up to that panorama’s capture date are returned.
- depth: ndarray = None¶
The legacy depth maps of the cubemap faces.
- has_equirect: bool = None¶
If True, this panorama can be fetched as either in equirectangular projection or as a cubemap. If False, only a cubemap is available.
- panorama_type: PanoramaType = None¶
The panorama type. Most identifiers are taken directly from the source.
- overlay: Overlay | None = None¶
Curiously, in non-3D imagery, Naver masks their car twice: once with an image of a car baked into the panorama, and additionally with an image of the road beneath it (like Google and Apple), which is served as a separate file and overlaid on the panorama in the client. This is the URL to that secondary overlay.
(Only available for non-3D car footage.)
- property tile_size: Size¶
Naver panoramas in equirectangular format are broken up into a grid of tiles. This returns the size of one tile.
- permalink(heading=0.0, pitch=10.0, fov=80.0, map_zoom=17.0, radians=False)[source]¶
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 10°.
fov (float) – (optional) Initial FOV of the viewport. Defaults to 80°.
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 (NaverPanorama)
- Returns:
A Naver Map URL which will open this panorama.
- Return type:
- class Neighbors(street, other)[source]¶
Nearby panoramas.
- Parameters:
street (List[NaverPanorama])
other (List[NaverPanorama])
- street: List[NaverPanorama]¶
Nearby panoramas taken at street level.
- other: List[NaverPanorama]¶
Nearby aerial or underwater panoramas.
- class Overlay(source, mask)[source]¶
URLs to the images from which the overlay hiding the mapping car is created.
- class PanoramaType(*values)[source]¶
The panorama type. Most identifiers are taken directly from the source.
- ALL = 0¶
- AIR = 1¶
- DRONE = 2¶
- CAR = 3¶
- BICYCLE = 4¶
- MUSEUM = 5¶
- PENSION = 7¶
- PENSION_FRONT = 8¶
- INDOOR = 10¶
- INDOOR_HIGH = 11¶
- UNDERWATER = 12¶
- TREKKER = 13¶
- NO_MESH_EQUIRECT = 14¶
A panorama which can be fetched in equirectangular projection.
- MESH_EQUIRECT = 15¶
An Apple-like panorama which can be fetched in equirectangular projection and for which a 3D mesh is available.
- SPACE = 20¶
- UNKNOWN = 99¶
- INDOOR_3D = 100¶
Miscellaneous¶
- build_permalink(id, heading=0.0, pitch=10.0, fov=80.0, map_zoom=17.0, radians=False)[source]¶
Creates a permalink to the given panorama.
- Parameters:
id (str) – The pano ID.
heading (float) – (optional) Initial heading of the viewport. Defaults to 0°.
pitch (float) – (optional) Initial pitch of the viewport. Defaults to 10°.
fov (float) – (optional) Initial FOV of the viewport. Defaults to 80°.
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 Naver Map URL which will open the given panorama.
- Return type: