aspectumapp / osm2geojson

Convert OSM and Overpass XML/JSON to GeoJSON
MIT License
97 stars 15 forks source link

json2shapes function results in segmentation fault #19

Closed askonivala closed 3 years ago

askonivala commented 3 years ago

This code:

query = '[out:json]; way[wikidata="Q420810"]; out geom;'
result = osm2geojson.overpass_call(query)
json_dict = json.loads(result)
geo_json = osm2geojson.json2shapes(json_dict)

Results in:

Fatal Python error: Segmentation fault

Current thread 0x00007f50d41f1740 (most recent call first):
  File "/home/XXX/anaconda3/envs/ritter/lib/python3.8/site-packages/shapely/geometry/polygon.py", line 494 in geos_polygon_from_py
  File "/home/XXX/anaconda3/envs/YYY/lib/python3.8/site-packages/shapely/geometry/polygon.py", line 240 in __init__
  File "/home/XXX/anaconda3/envs/YYY/lib/python3.8/site-packages/osm2geojson/main.py", line 257 in way_to_shape
  File "/home/XXX/anaconda3/envs/YYY/lib/python3.8/site-packages/osm2geojson/main.py", line 108 in element_to_shape
  File "/home/XXX/anaconda3/envs/YYY/lib/python3.8/site-packages/osm2geojson/main.py", line 78 in _json2shapes
  File "/home/XXX/anaconda3/envs/YYY/lib/python3.8/site-packages/osm2geojson/main.py", line 47 in json2shapes
  File "get_osm_polygons.py", line 17 in <module>
Segmentation fault (core dumped)
rapkin commented 3 years ago

I tested your example and received correct geometry. I think problem with shapely (it uses c extensions). Can you try to reinstall shapely conda install shapely --force-reinstall?

askonivala commented 3 years ago

Thanks a lot! Yes, the shapely installation in my virtual environment is indeed broken. Sorry about this, I should have understood that from the debug message.