1

I have an file that is in the format .osm.pbf. It's about 8GB. I want to convert it to a feature class and place it in a file geodatabase. From what I can see, the simplest way to do that is using gdal and ogr2ogr. I had both installed with my OSGeo/QGIS. The gdal and ogr2ogr package files and executables are in my C:\OSGeo4W64\bin folder. Initially, I tried converting to a shapefile but ran into problems. I tried running the following command:

ogr2ogr -f "ESRI Shapefile" mydata.shp mydata.osm.pbf

I immediately got the following error messages:

Warning 1: Cannot find osmconf.ini configuration file
ERROR 1: Could not parse configuration file for OSM import
FAILURE:Unable to open datasource `na_test.osm.pbf' with the following drivers.
  -> `JP2ECW'
  -> `OCI'
  ...
  -> `OSM'

I see that I have an 'OSM' driver, but it seems that either a) I don't have osmconf.ini or its in the wrong spot, or b) I need to configure something in osmconf.ini so that it can open a .osm.pbf file. I do have a osmconf.ini, but its in my C:\OSGeo4W64\share folder. I tried copying it and placing it in 'binbut that didn't seem to do any good. My system variable path is pointing to 'C:\OSGeo4W64\bin. In addition to this, I realized that there is no way I am converting 8GB + osm files into a shapefile and I need to convert them to feature classes or geojson if possible. Help, is there a way to do this? Is ther something wrong with my gdal configuration?

Side Note: I do have gdal and ogr2ogr working in a Python 3.x environment with Pandas/Geopandas.

1 Answer 1

2

It should find the osmconf.ini local to the installation. You can override it using -oo CONFIG_FILE=<yourpath>/osmconf.ini on the command line.

You are probably also going to want to adjust your osmconf.ini to specify what is imported and what ignored. Also, how to handle closed ways,etc.

Yes shapefiles would be a bad choice. As would GeoJSON. You think PBF is big? This is a compressed binary format: Wait until you see a GeoJSON equivalent!

You could look at spatialite as one alternative. Also if you are serious about 8GB compressed files, then PostGIS should be seriously considered. Of course it all depends on what you are trying to do with the data.

Also note that the data is going to be imported with one 'layer' for each geometry type (point, linestring, etc) and not by feature type (road, river, etc).

3
  • you wrote "You are probably also going to want to adjust your osmconf.ini to specify what is imported and what ignored. Also, how to handle closed ways,etc". So, how would I do that? Specifically for a.pbf file? In the osmconfig.ini file, I see it is broken down by geometry type and that there are attribute keys, unsignificant keys, etc...but I really have no idea how to configure any of this. Suggestions?
    – gwydion93
    Oct 8, 2019 at 14:29
  • 1
    Yes. I think you need to read up on OpenStreetMap data and how it is structured. Their website is a good start, eg: wiki.openstreetmap.org/wiki/Beginners_Guide_1.3 Note it doesn't matter if you are using their native XML (which might be easier to think of) or the more opaque PBF - these structure the data in the same way. I think first you should try looking at a smaller data file. This will give you an idea of what the data looks like. Perhaps try QGIS or JOSM to have a look at a small section?
    – winwaed
    Oct 8, 2019 at 14:41
  • 1
    I think that needs to be -oo CONFIG_FILE=<yourpath>/osmconf.ini instead of -o Nov 22, 2021 at 22:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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