Getting coordinates of ways with Overpass API osm script

by thposs   Last Updated August 14, 2019 16:22 PM

I realize there are questions similar to this one but after looking at them, I still can't fix my problem.

I would like to get all the node coordinates for the nodes along all the road ways in some area. Right now I can only get which nodes are contained in the way (w/o their coords). From answers to other questions here I think that I need to change the print mode to geom but I can't get it to work.

Here's my query:

<osm-script output="json" timeout="25">
  <!-- gather results -->
    <query type="way">
      <has-kv k="highway"/>
      <has-kv k="highway" modv="not" v="footway"/>
      <has-kv k="highway" modv="not" v="pedestrian"/>
      <has-kv k="-highway" modv="not" v="path"/>
      <bbox-query s=" """ + str(s) + '" w="' + str(w) + '" n="' + str(n) + '" e="' + str(e) + '"/>' + """
  <!-- print results -->
  <print mode="skeleton"/>
  <recurse type="down"/>
  <print mode="geom" order="quadtile"/>

(Note: vars s, w, n, and e are the max/min long and lat coords defined elsewhere)

When trying to convert the output to Json:

response = requests.get(overpass_url, params={'data': overpass_query}, proxies=proxies)
data = response.json()

I get the following error:

---> 37 data = response.json()
JSONDecodeError: Expecting value: line 1 column 1 (char 0)

I can provide the original query that results in a Json w/ the nodes in each way but w/o their coordinates if that is necessary, but I thought it might be overkill.

Tags : openstreetmap

Related Questions

Import OSM Notes dump into postgresql

Updated June 01, 2015 09:09 AM

How do I reference an OSM object?

Updated June 22, 2015 02:09 AM

OSMBuilding add 3D model, how?

Updated March 17, 2017 17:22 PM

Export OSM data from my own server

Updated March 22, 2017 17:22 PM