QuickOSM
QuickOSM copied to clipboard
Import super-relations contained in .osm files
Is your feature request related to a problem? Please describe
We have .osm files containing many (hiking) routes that are super-relations. We need to import these relations into QGIS for further analysis, but have not found a way to do so. QuickOSM only imports the lowest hierarchy of the relations.
Describe the solution you'd like
It would be great if QuickOSM could import these relations of relations the same way other relations are currently imported (as their own Multilinestring with the key "osm_type"='relation')
It's not going to be an easy task. OSM files are opened by OGR: https://www.gdal.org/drv_osm.html
It's clearly stated that OGR supports only relation type route
, multipolygon
, boundary
. All other relations fail in other_relations
layer, which is not loaded by default in QuickOSM.
In QGIS 2, you could use some Processing algorithms to work with these relations. But I didn't get enough time to port them in QGIS 3, see ticket https://github.com/3liz/QuickOSM/issues/146
https://github.com/3liz/QuickOSM/issues/146
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.
+1. It seems the issue ultimately boils down to the limitations of the OSM database's relational capabilities. Having said that there are surely workarounds that would 'flatten' relations into layers containing all reference features at any depth, much as JOSM's 'Export as GPX' feature does for route relations.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.
QGIS 3.10 seems to be able to import such other relations by drag-and-drop. But all the tags will be included in a other_tags column, this at least can be later corrected using a few commands with regex to created new columns. But the main problem QGIS will only import the first 99 ones!
QGIS 3.10 seems to be able to import such other relations by drag-and-drop
But do you have a geometry? Other type than route
, multipolygon
, boundary
?
this at least can be later corrected using a few commands with regex to created new columns
Use the Explode HStore
algorithm, it will do that for you without any regex.
QGIS 3.10 seems to be able to import such other relations by drag-and-drop
But do you have a geometry? Other type than
route
,multipolygon
,boundary
?
No I don't, and I don't want one anyway. I want to have a listing of values taken from those relations. I should have more than 4K of them, but I only get 99, it seems to be the very first 99 ones.
this at least can be later corrected using a few commands with regex to created new columns
Use the
Explode HStore
algorithm, it will do that for you without any regex.
Thank you it did the job.
I made a test exporting in PBF. Surprisingly, QGIS will convert exactly 2575 features in PBF, while it will only convert 99 of them in OSM XML. Strange. 2575 is better than 99, but I am still missing a lot of features from my file.
I got it working by adding this to ogr2ogr.
--config OSM_USE_CUSTOM_INDEXING NO
I come back on this subjects. Could QuickOSM use a shell script to convert in JSON instead to import those kind of relations?
That what I have resigned to use. It works better and I use shell scripts with awk and sed commands that do the job perfectly well.
Maybe QuickOSM could include the same with the script being written by the settings the user will choose? With this process you can even keep, on not, roles or segments if they are some.
With this simple script, you can keep for example only the route_master relations. It will keep all the items included between the <relation>…</relation>
tags.
cat my_file.osm | \
sed -e 's/^[ \t]*//' | \
name="k='type' v='route_master'" \
awk -v name="$name" '$0 ~ ENVIRON["name"] {print "<relation" $0 "</relation>"}' RS="<relation|</relation>"