2

I am working with a self-installed version of the Overpass API.

I need to be able to query all street names in a particular city, Inverness in the United Kingdom (GB). There is also a city called Inverness in Florida, United States.

Therefore I need a query which limits the results returned to Inverness in GB.

This is the query that I have tried but it returns an empty result set.

[out:json]; 
(area["ISO3166-1"="GB"][admin_level=2]; )->.country;
(area["name"="Inverness"])->.city;
(way(country)(city)[highway]; ); 
(._;>;);
out;

How can I reformulate the query to return the information that I need?

1

Looking at the Inverness node suggests that it isn't in GB (it isn't really an admin unit).

is_in   Highland;Scotland;United Kingdom;Europe
is_in:continent Europe
is_in:country   Scotland
is_in:iso_3166_2    SCT
is_in:province  United Kingdom
name    Inverness

So I would try something like:

[out:json]; 
(area["ISO3166-2"="GB-SCT"][admin_level=4]; )->.country;
(area["name"="Inverness"])->.city;
(way(country)(city)[highway]; ); 
(._;>;);
out;
|improve this answer|||||
  • 1
    Actually it is in GB. Please note that most OSM keys are lowercase, so Country should be country instead. However, Scotland has admin_level=4 (see admin_level values for specific countries) and no Country key set. Better query for area["ISO3166-2"="GB-SCT"][admin_level=4]. – scai Jan 3 at 9:07
0

Your query syntax looks wrong. Try the following instead:

[out:json];
area["ISO3166-1"="GB"][admin_level=2]->.country;
area["name"="Inverness"]->.city;
way(area.country)(area.city)[highway];
(._;>;);
out;

Although I'm not sure if this query is ideal for your task or if it can be optimized.

|improve this answer|||||

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.