[gdal-dev] How to replace an osm key?

Rahkonen Jukka (MML) jukka.rahkonen at maanmittauslaitos.fi
Fri Nov 11 06:14:29 PST 2016


Hi,

Ogrinfo and ogr2ogr usually accept the same syntax and therefore I gave the ogrinfo example. I apologize, it can’t be self-evident for all GDAL users.

You can do the whole thing with one command like this:

ogr2ogr.exe --config OSM_USE_CUSTOM_INDEXING NO -skipfailures -f "ESRI Shapefile"
-dialect sqlite –sql "select geometry, building as bldg from multipolygons” output.shp input.osm

You must edit the SQL parameter to include all the fields that you want to get into the result  "select geometry, building as bldg, another_attribute as attr_2 …” and you must run the query separately for all the layers ( points, lines, multilinestrings, multipolygons).

-Jukka Rahkonen-



Djordje Spasic wrote:

Hi Jukka,

Thank you for the quick and informative reply!

But I am not sure I understood you.

So first I need to convert the .osm file to .shp files with ogr2ogr.exe
And then I am calling the ogrinfo.exe on specific .shp file (multipolygons.dbf ?)

ogr2ogr.exe --config OSM_USE_CUSTOM_INDEXING NO -skipfailures -f "ESRI Shapefile" output.shp input.osm

ogrinfo.exe -dialect sqlite -sql "select geometry, building as bldg
from output.shp/multipolygons.dbf" input.osm.pbf

?

On Friday, November 11, 2016 2:36 PM, jratike80 <jukka.rahkonen at maanmittauslaitos.fi<mailto:jukka.rahkonen at maanmittauslaitos.fi>> wrote:

Hi,

You can rename the fields with SQL

ogrinfo -dialect sqlite -sql "select geometry, building as bldg
from multipolygons" hamburg-latest.osm.pbf

....
Geometry Column = GEOMETRY
bldg: String (0.0)
....

Slight drawback is that you must include all the attributes in SELECT but
you can save the command into text file for reuse.

-Jukka Rahkonen-



--
View this message in context: http://osgeo-org.1560.x6.nabble.com/gdal-dev-How-to-replace-an-osm-key-tp5295339p5295342.html
Sent from the GDAL - Dev mailing list archive at Nabble.com.
_______________________________________________
gdal-dev mailing list
gdal-dev at lists.osgeo.org<mailto:gdal-dev at lists.osgeo.org>
http://lists.osgeo.org/mailman/listinfo/gdal-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20161111/a6ab5105/attachment-0001.html>


More information about the gdal-dev mailing list