2

I am looking for a solution that works with the overpass api.

for example:

http://overpass-api.de/api/interpreter?data=[out:geojson];area(3600225494);(node(area)[%22amenity%22~%22theatre|cinema|arts_centre%22];);out%20body;

When trying this approach I get an error that says

"Error: line 1: static error: For the attribute "output" of the element "osm-script" the only allowed values are "xml", "json", "csv", "custom", or "popup"."

Therefore GeoJSON is not supported this way.

I tried several approaches in ipython (python 2.7) to transform json into geojson, but failed so far.

What I need is a way to get OSM as geojson in ipython via using a url (e.g. overpass api).

BR

7

Overpass API doesn't support GeoJSON. You have to perform the conversion from JSON to GeoJSON yourself.

For converting JSON into GeoJSON see this answer. It even contains a solution in Python. Another Python solution is contained in this answer.

  • Thanks! For confirming/clarifying my issue and also providing a possible solution. Will try it out the first solution and let you know later. The second solution I already tried and hat some problem with the d["lon"] – Apachai Dec 7 '16 at 13:56
  • 2
    To elaborate: adding geojson output to the overpass API was discussed and rejected here github.com/drolbr/Overpass-API/issues/48, because semantics are unclear for e.g. closed ways. They then mention github.com/tyrasd/osmtogeojson as a way to produce geojson from OSM data. – til_b Dec 7 '16 at 14:23
  • @scai I tried it out and both approaches return a KeyError: KeyError Traceback (most recent call last) <ipython-input-152-f46acadcf165> in <module>() ----> 1 v = convert_json(data) <ipython-input-151-b6174edc078d> in convert_json(items) 10 if key not in ('lat', 'lon') } 11 } ---> 12 for feature in json.loads(items) 13 ] 14 }) KeyError: 'lon' – Apachai Dec 7 '16 at 20:57

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.