How can I obtain semantically correct WKT geometries for a OSM way or relation or node?

Well node is simple and way as well, but I am struggling with the relations which can contain many ways:

For example the relation https://www.openstreetmap.org/relation/2764083 contains two ways https://www.openstreetmap.org/way/26128247 and https://www.openstreetmap.org/way/205746186#map=18/48.21971/16.35130 which form the border.

However, how can I ensure that when I create a line string the whole (single) border is returned in a semantic correct way? A simple GROUP BY then collect_list for the ID of the relation on any of the nodes matching can only return the separate relations as LINESTRINGs. How could these be merged in the right way or better a proper single geometry be returned in the first place?

I looked at the SQL from https://github.com/mojodna/osm2orc for inspiration but still struggle with the relations.

1 Answer 1


For nodes and ways see https://georgheiler.com/2019/05/07/analyze-osm-data-in-spark/

Only relations are missing from now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.