This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

Overpass API Interpreter Help

1

I'm having trouble executing my query using the overpass-api.de API.

Error: line 3: parse error: not well-formed (invalid token)

My query is the following:

<osm-script timeout="300">
  <id-query {{nominatimArea:Mexico}} into="area"/>
  <union>
    <query type="node">
      <has-kv k="amenity" v="parking"/>
      <area-query from="area"/>
    </query>
    <query type="way">
      <has-kv k="amenity" v="parking"/>
      <area-query from="area"/>
    </query>
    <query type="relation">
      <has-kv k="amenity" v="parking"/>
      <area-query from="area"/>
    </query>
  </union>
  <print mode="body"/>
  <recurse type="down"/>
  <print mode="skeleton" order="quadtile"/>
</osm-script>

Any suggestions?

asked 02 Jan '15, 13:42

turgus's gravatar image

turgus
31113
accept rate: 0%


One Answer:

3

{{nominatimArea:Mexico}} is overpass turbo specific (=syntactic sugar). Overpass API (the database backend) has no idea about this, hence the error message you get.

Just paste your query into overpass-turbo.eu and click on Export. What you're probably looking for is the link behind "raw data directly from Overpass API".

Before sending your query to Overpass API, overpass turbo will automatically replace this by

<id-query type="area" ref="3600114686" into="area"/>

answered 02 Jan '15, 14:25

mmd's gravatar image

mmd
5.7k15388
accept rate: 37%

edited 02 Jan '15, 14:29

Doing that, the second line became: <id-query type="area" ref="3600114686" into="area"/>

Is there anyway I can find out the ref number somehow without overpass turbo doing all the work?

(02 Jan '15, 14:29) turgus
2

Yes, sure, something along those lines:

<query into="area" type="area"> <has-kv k="boundary" v="administrative"/> <has-kv k="ISO3166-1" v="MX"/> </query>

(02 Jan '15, 14:32) mmd

Thanks a ton!

(02 Jan '15, 14:33) turgus
1

overpass turbo link: http://overpass-turbo.eu/s/6Nb

(02 Jan '15, 14:33) mmd

Sorry, one last question. Let's say I had:

<query into="area" type="area"> <has-kv k="boundary" v="administrative"/> <has-kv k="ISO3166-1" v="US"/> </query>

and wanted to get only the state Florida from US?

Edit: Nevermind, got it! Thanks again

(02 Jan '15, 14:36) turgus
1

Florida's relation (www.openstreetmap.org/relation/162050) is currently tagged as "ISO3166-2"= "US-FL", "admin_level"="4" and "boundary" = "administrative".

So I would probably use <has-kv k="ISO3166-2" v="US-FL"/> along with <has-kv k="boundary" v="administrative"/>

(02 Jan '15, 14:40) mmd
showing 5 of 6 show 1 more comments

Source code available on GitHub .