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.

  • If you "realize there are questions similar to this one", then can you provide links to them within your question body, please? Even if potential answerers end up deciding your question is new, reviewing those may trigger ideas on how to answer yours.
    – PolyGeo
    May 13, 2020 at 22:38

1 Answer 1


Kind of solved it.

Had to use QL instead of XML to get it to work but here is what I used:

import requests
import overpass
api = overpass.API()

s = 12
w = 34
n = 56
e = 78

data = api.get('way(' + str(s) + ',' + str(w) + ',' + str(n) + ',' + str(e) +
           ')["highway"!~"footway"]' + 
           '["highway"!~"pedestrian"]["highway"!~"path"]' +
           verbosity = 'geom')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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