Search code examples
geolocationopenstreetmapoverpass-api

Difference between geocode area, bbox, and area in OSM turbo query?


When using overpass turbo to query the OpenStreetMaps data I am finding different results when I define the search area using geocode area, bbox, and area.

For example:

Geocode Area

[out:json]
{{geocodeArea:Bulacan, Philippines}}->.searchArea;

Area

[out:json]
area["ISO3166-2"="PH-BUL"];

and one can also use bbox as well.

However, when I use Geocode area vs the area command I get different resulting outputs for the same query. In the Geocode version I get many more data points whereas in the area query I get just one. Is there any specific reason why this is the case?

How does the geocodeArea work vs area in the above example? Shouldn't these statements be equivalent?


Solution

  • In fact both areas are exactly the same:

    {{geocodeArea:Bulacan, Philippines}}->.searchArea;
    .searchArea out;
    
    area["ISO3166-2"="PH-BUL"];
    out;
    

    As you haven't provided a full query in your question, most likely the issue is caused by the lack of .searchArea in the second example. Due to this the query result would be stored in a default set ._ instead. If you're not careful enough, this default set gets easily overwritten by subsequent statements in your query.

    So by replacing

       area["ISO3166-2"="PH-BUL"];
    

    by

       area["ISO3166-2"="PH-BUL"]->.searchArea
    

    you should get exactly the same results.