2

If I look up a city on openstreetmap, I can see it has an administrative level of 10. For example: https://www.openstreetmap.org/relation/162798

Subsequently, I run a query in Overpass Turbo to extract the aministrative boundary of this city:

[out:json][timeout:60];    
{{geocodeArea:'s-Hertogenbosch}}->.searchArea;
    relation["admin_level"="10"](area.searchArea);
);

out body;
>;
out skel qt;

{{style: 
  area
  { color:gray; fill-color:DarkGray; }
}}

However, this does not work (returns an empty dataset). If I set the admin_level to 8, it returns a much bigger area compared to what openstreetmap shows. For other cities, the admin_level 10 does work, so why not for 's-Hertogenbosch? Am I missing something here?

0

If you already know the name and the admin_level then just query directly for this element:

[out:json][timeout:60];    
relation["name"="'s-Hertogenbosch"]["admin_level"="10"];
out body;
>;
out skel qt;

Unfortunately I can't tell why your original query fails.

1
  • Thanks. I don't know why I didn't try to query it directly. Thinking too difficult again. But still strange that the original query results in an empty dataset.
    – jrp500
    Apr 9 '20 at 9:28
0

You should use pivot instead of querying for a relation inside itself. This is also more generic: you only need to know that the geocodeArea is a relation, but don't know the admin_level. What ends up in ".searchArea" depends on the "Nominatim" lookup that overpass turbo runs before sending the query to Overpass API. Results may be a bit random at times.

[out:json];    
{{geocodeArea:'s-Hertogenbosch}}->.searchArea;
rel(pivot.searchArea);
out geom;

{{style: 
  area
  { color:gray; fill-color:DarkGray; }
}}

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.