3

The website http://download.geofabrik.de/north-america.html does not have shapefiles (shp.zip) for sizable states or countries. How do you convert the available osm.pbf to shp.zip?

I have tried QGIS but it does not export all the shapefiles from (osm.pbf) to (shp).

I have tried R, but again, only exported a fraction of shapes.

library(rgdal)

osmfilename = 'california-latest.osm.pbf'
directory_name = 'shp_directory'
layer_name = 'output_layer'
osm <- readOGR(osmfilename, 'lines')
writeOGR(osm, directory_name, layer_name, driver = 'ESRI Shapefile')

Do you have any other way that I could try?

  • I guess that shp.zip packages are missing because of the 2 GB size limit of shapefile. Convert into GeoPackage, ArcGIS should read it fine and if it does not, contact your ESRI support and try to file a bug. – user30184 Oct 2 at 15:42
  • @user30184 surprisingly the size of the output shapefile is only 70MB (using R). I think the "lines" in the osm.pbf doesnot, for some reason, contain all the lines in the shapefile. – pnkjmndhl Oct 2 at 15:59
  • Compare your results with GDAL. Start with ogrinfo -al -so california-latest.osm.pbf. – user30184 Oct 2 at 16:09
1

OSM data has a lot of different data types, tags, etc. It is probably best as a lot of different shape files. You could import it into a Spatialite file using either OGR2OGR or QGIS, and then extract each layer type that makes sense for your application. Eg. one for roads, one for roads, one for linear water features, another for polygon water features.

(as an aside, I am currently writing a QGIS plugin that will import certain "feature types" into layers from a PBF file. The required use case was for Admin Areas, but I am adding other feature types like water, buildings, etc. Let me know if you're interested in testing it. I intend to put it in the main plugin repository and on github)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.