I do some research involed within geomorphology and I wanted to see if it were possible to extract all riverbank features of openstreetmaps. I’ve downloaded the 13.8gb pbf file from http://download.bbbike.org/osm/planet/ and i’ve attempted to process the data by the following commands
Check first that the osmconf.ini file includes waterway attribute for lines
# common attributes
# keys to report as OGR fields
The command which saves all the waterway lines from the OSM extract of Finland into a shapefile is
ogr2ogr -f "ESRI Shapefile" -sql "select * from lines where waterway is not null" osm_waterways.shp finland.osm.pbf
It took 4 minutes with an old laptop to run the command and convert 19324 features into a shapefile. I have never tried this with the planet file and it may be too big for GDAL. The result is for sure GIS compatible and it does not need to be shapefile but any format that GDAL/OGR supports for writing can be used as well http://gdal.org/ogr/ogr_formats.html
Id like to ask a follow up question if you don’t mind. Would you know how to apply a similar concept but using the “othertags” that are not part of the osmconf.ini? As expected the entire world is too big to save as a shapefile but it does include a lot of unecessary when using waterway that I dont need. The docs say
When keys are not strictly identified in the osmconf.ini file, the key value pair is appended in a “other_tags” field, with a syntax compatible with the PostgreSQL HSTORE type. See the COLUMN_TYPES layer creation option of the PG driver.
I am not sure about what you want to do exactly but the following command creates the points, lines, multilinestrings, multipolygons, and other_relations tables into PostGIS and saves attributes which are not converted into normal attributes to hstore field. Parameters -progress and -gt are not necessary. You can read what they mean from ogr2ogr documentation.
Notice, that the fields which you want to use in SQL select must be included in the list of normal OGR attributes, and that means that they will not go to “other_tags” field. GDAL is not perfect for filtering OSM data.