Hi,
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
[lines]
# common attributes
osm_id=yes
osm_version=no
osm_timestamp=no
osm_uid=no
osm_user=no
osm_changeset=no
# keys to report as OGR fields
attributes=name,highway,waterway,aerialway,barrier,man_made
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
Hi JRA,
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
“other_tags” field
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’ve tried to follow the documentation there but i dont quiet understand how to apply hstore to my particular case and considering osm is a new feature i dont see any tutorials online.
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.