Repository navigation
Help Needed: Loading pbf file #2387
|
Hello. Basically:
Now I am wondering how I can load this file into my program. |
Replies: 1 comment 3 replies
|
It depends on what the Case 1: it's a vector tile ( pip install folium-vectorgridimport folium
from folium_vectorgrid import VectorGridProtobuf
m = folium.Map(location=[48.85, 2.35], zoom_start=12, tiles=None)
VectorGridProtobuf("http://localhost:8080/data/v3/{z}/{x}/{y}.pbf", "my-tiles", {}).add_to(m)
m.save("map.html")(You can serve the Case 2: it's an OSM extract ( from pyrosm import OSM
roads = OSM("area.osm.pbf").get_network("driving")
folium.GeoJson(roads.to_json()).add_to(m)The simpler fix for the 403 m = folium.Map(location=[48.85, 2.35], zoom_start=12, tiles="CartoDB positron")Your browser also caches tiles, so refreshing doesn't download them all again. |
It depends on what the
.pbffile is. Folium (Leaflet) displays map tiles, not raw map data, so you have two different cases:Case 1: it's a vector tile (
.pbffrom a{z}/{x}/{y}.pbftile URL)A single tile only covers one small square at one zoom level, so it's not very useful on its own. For a whole area, use an
.mbtilesfile, serve it locally, and render it with the VectorGrid plugin:(You can serve the
.mbtileswith e.g.