I would like to open a .osm.pbf using fiona in Python. I can't find much documentation on this. How can I does one do this?
I have done it using ogr2ogr.
1 Answer 1
Fiona is by design restricted to the conventional record model of data, i.e. all records (features) have the same fields associated with them. This means that Fiona reads shapefiles, but does not read more flexible formats such as the OSM PBF format.
You can check which drivers are supported in Fiona with:
import fiona
list(fiona.drivers)
You have two options then: use the OGR Python drivers to read the data, or to use ogr2ogr
to convert the data to a format that Fiona can read. I think the second option is your best bet as I find Fiona much easier to use.
-
1Check out gdal.org/drv_osm.html. OGR reads PBF into a temporary SQLite database. This violates my sense of what's appropriate for a library to do and so Fiona is going to keep the OSM driver turned off. Do use ogr2ogr or OSM-native software like Osmosis.sgillies– sgillies2014年08月19日 15:38:53 +00:00Commented Aug 19, 2014 at 15:38