Visualizing Mapillary Vector Tiles
Mapillary provides a global dataset of street-level images, with coverage in many countries. The Mapillary vector tiles provide a way to access the data in a vector format, which can be used to create custom maps and visualizations.
Uncomment the following line to install leafmap if needed.
In [1]:
Copied!
# %pip install "leafmap[maplibre]"
# %pip install "leafmap[maplibre]"
In [2]:
Copied!
import leafmap.common as common
import leafmap.maplibregl as leafmap
import leafmap.common as common
import leafmap.maplibregl as leafmap
To run this notebook, you will need an access token from Mapillary. Once you have the API key, you can uncomment the following code block and replace YOUR_API_KEY
with your actual API key. Then, run the code block code to set the API key as an environment variable.
In [3]:
Copied!
# import os
# os.environ["MAPILLARY_API_KEY"] = "YOUR_API_KEY"
# import os
# os.environ["MAPILLARY_API_KEY"] = "YOUR_API_KEY"
In [4]:
Copied!
m = leafmap.Map(style="bright", center=[-73.99941, 40.71194], zoom=13)
m.add_mapillary(minzoom=6, maxzoom=14, add_popup=True)
m.add_layer_control()
m
m = leafmap.Map(style="bright", center=[-73.99941, 40.71194], zoom=13)
m.add_mapillary(minzoom=6, maxzoom=14, add_popup=True)
m.add_layer_control()
m
In [5]:
Copied!
image_ids = common.search_mapillary_images(
lon=-73.99941, lat=40.71194, radius=0.0005, limit=5
)
image_ids
image_ids = common.search_mapillary_images(
lon=-73.99941, lat=40.71194, radius=0.0005, limit=5
)
image_ids
Out[5]:
['584598932517576', '314851193648213', '464835057923297', '479768769908510', '318780713054379']
In [6]:
Copied!
common.get_mapillary_image_url(image_ids[0], resolution="original")
common.get_mapillary_image_url(image_ids[0], resolution="original")
Out[6]:
'https://scontent-iad3-1.xx.fbcdn.net/m1/v/t6/An940g4aKm6u_qh6v4lq_tfpsXUCHGmOUTcrVGmtmXW-3_fGLnRPQeYmKH1EhCo-G4K_Me2kBbzLDnfnO3NAheFIszRfddMOsu5OstmtVi01J8t4qg7-oeLbDkU1dZUJRPUWzDJLhiLV2JjF8Voa-Tw?ccb=10-5&oh=00_AYCnkfiZ__1D4FZF9tB-dV7T3_sc2l3pFMdAzpqphNSE0A&oe=67857A30&_nc_sid=201bca'
In [7]:
Copied!
common.download_mapillary_images(image_ids, resolution="original")
common.download_mapillary_images(image_ids, resolution="original")
Downloading 1/5: 584598932517576.jpg ...
Downloading 2/5: 314851193648213.jpg ...
Downloading 3/5: 464835057923297.jpg ...
Downloading 4/5: 479768769908510.jpg ...
Downloading 5/5: 318780713054379.jpg ...
In [8]:
Copied!
common.get_mapillary_image_widget(image_ids[0], style="classic", width=1000)
common.get_mapillary_image_widget(image_ids[0], style="classic", width=1000)
In [9]:
Copied!
common.get_mapillary_image_widget(image_ids[0], style="split", width=1000)
common.get_mapillary_image_widget(image_ids[0], style="split", width=1000)
In [10]:
Copied!
common.get_mapillary_image_widget(image_ids[0], style="photo", width=1000)
common.get_mapillary_image_widget(image_ids[0], style="photo", width=1000)