6

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?

3
  • 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
    Commented Oct 2, 2019 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
    Commented Oct 2, 2019 at 15:59
  • Compare your results with GDAL. Start with ogrinfo -al -so california-latest.osm.pbf.
    – user30184
    Commented Oct 2, 2019 at 16:09

1 Answer 1

2

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)

1
  • Any update on the extension?
    – mmann1123
    Commented Mar 23, 2022 at 14:26

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