[gdal-dev] splitting other_tags from .osm file

Even Rouault even.rouault at spatialys.com
Sat Oct 29 13:00:50 PDT 2016


Le samedi 29 octobre 2016 21:36:43, Djordje Spasic a écrit :
> Hello,
> 
> I am converting an .osm file to a .shp file with OGR2OGR.exe. Here is an
> example: ogr2ogr.exe --configOSM_USE_CUSTOM_INDEXING NO -skipfailures -f
> "ESRI Shapefile"output.shp input.osm In osmconf.ini the "other_tags" is
> set to "yes" (other_tags=yes).
> 
> Is it possible to somehow tell the OGR2OGR to split the "other_tags" string
> into all of those separate tags it contains? Or maybe to somehow do that
> by editing the osmconf.ini file?
> 
> I googled, and checked the GDAL OSM driver page, but still couldn't find an
> answer.

Djordje,

There's no option to do that. This would require doing a 2 pass strategy :
* a initial pass in to collect all the possible tags so as to discover all the 
needed fields
 * and then the real pass to read the data.

(We could potentially do that in a single pass if we allowed the layer 
definition to be modified while reading, but this isn't something that is 
allowed in the OGR "contract" with respect to code using the API. We could 
imagine an option where code ready for that (for example an updated ogr2ogr) 
would tell the reader: you can declare new fields as soon as you discover them)

So you have to do that as a post processing step with some scripting (could be 
a useful contribution).

Or edit osmconf.ini to add the extra tags you want as fields in the attribute= 
configuration key, as I'm not sure you really need all exotic tags to be 
individualized as OGR fields.

Or actually you could do a simplified osm2shape.py that would be a simplified 
ogr2ogr that would read the .osm file, and split other_tags on the fly.

Even

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list