Closed thagorx closed 3 years ago
Can you give me example?
relation 1899923 for example has nodes, lines and polygons
Ok, I made overpass query https://overpass-turbo.eu/s/132c
Converted JSON-data to GeoJSON:
import json
import codecs
from osm2geojson import json2geojson
def read_data_file(path):
with codecs.open(path, 'r', encoding='utf-8') as data:
return data.read()
json_data = json.loads(read_data_file('./data_from_overpass.json'))
geo_data = json2geojson(json_data)
f = open('./result.geojson', 'w')
f.write(json.dumps(geo_data, indent=2))
f.close()
And I see all geometry (1 polygon, lines and points) in result file.
Also I compared result with overpass map
You can see more points (osm2geojson converts all geometry without filtration), but you can easily filter them by tags.
Did it help you?
Yes this helps kind of :D my issues actually is a more complex dataset:
https://overpass-turbo.eu/s/134p
when I try to parse it with json2geojson
the library throws a couple of Failed to convert relation to shape
before it fails with KeyError: 'lon'
so my assumption was that there might be a problem with handling multi geometry relation.
But since then I wrote a parsers myself and I think the issue is rather, that for some relation not all sub elements are retrieved with Overpass QL.
Yes. Overpass can send partial data. But problem with KeyError: 'lon'
looks suspicious. I think that lib should return all valid geometry if it possible, so I'll try to reproduce this issue
I found problem with ids (in your example we have node with id 26763057 and way with id 26763057) - that was root of problems. I'm working on fix now.
Yeah ids are only unique within each geometry type
hey I stumbled upon this library and was wondering how does it handle a relation that contains multiple different types of geometry ?
cheers.