2

I am converting an .osm file to a .shp file with OGR2OGR:

ogr2ogr.exe --config OSM_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).

This creates an attribute other_tags which consists of a huge block of text, containing a lot of different tags.

Is it possible to somehow tell the OGR2OGR to split the other_tags into all of those tags it contains?

I searched, and found out that both in ArcGIS and QGIS there are options on how this can be done. but I am interested in doing it from OGR2OGR only.

1
  • Is it possible to somehow tell the OGR2OGR to split the other_tags into all of those tags it contains? can you clarify what you mean here, do you mean if you don't know in advance what the keys are?
    – nmtoken
    Nov 22, 2016 at 11:24

2 Answers 2

6

In QGIS 3.6, it is now possible to explode the "other_tags" HStore field. The algorithm will create one field for each unique key.

explode hstore field algorithm

2
  • Is QGIS 3.6 already released?
    – AndreJ
    Nov 24, 2018 at 17:11
  • In February 2019, but answers on SE are there for ever. And people might run QGIS dev
    – etrimaille
    Nov 24, 2018 at 17:23
2

Short answer: NO

Long answer:

It is necessary to know the possible keys within a .osm file before creating the GIS file of any format. So you have to scan the whole file twice: once for the keys, and once for the values.

This is basically the way that the QGIS QuickOSM plugin works. Since it is open-source, you can look into that and build your own importer. Preferably in Python to avoid porting code from one programming language to another.

1
  • Hi @AndreJ . I apologize for not seeing your reply back when you posted it. Thank you for it, and once again sorry for missing it.
    – marco
    May 31, 2017 at 18:57

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.