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

Using different city names

0

Hi,

I am using Overpass API to count the number of POIs for different categories and for different cities. However, the the city names I use, sometimes don't match the ones tagged in OSM.

Example: I use "Southbridge Town" but in OSM is listed as "Southbridge" (sometimes using "Southbridge Town" returns some POIs)

Example request:

[out:json][timeout:600];
area[admin_level=4]["name"="Massachusetts"]->.country;
area[place~"city|village|town|locality"]["name"="Southbridge Town"]->.city;
area["addr:city"="Southbridge Town"]->.address;
(
nwr(area.country)(area.city)["amenity"~"school"];
nwr(area.country)(area.address)["amenity"~"school"];
);     
out count;

I am looking for a general method for matching my city names with the ones used in OSM using regular expressions or Overpass tools. I use Python to build the query and make the request.

Thank you!

This question is marked "community wiki".

asked 09 Mar '22, 10:24

ocabanas's gravatar image

ocabanas
11113
accept rate: 0%

edited 09 Mar '22, 18:20


One Answer:

0

First to answer your question the solution is ot use the 'something like' operative which you've already used - [name~"Southbridge"]

However it's not required as there's only one Southbridge place.

addr:city is a tag of an object & can not be used to construct areas.

This routine returns the same results as your routine

area[admin_level=4][name=Massachusetts];
rel(area)[place=town][name=Southbridge];
map_to_area;
nwr(area)[amenity=school];
out geom;

answered 09 Mar '22, 18:03

DaveF's gravatar image

DaveF
3.3k8498133
accept rate: 16%

There was an error in my initial question. I use ["name"="Southbridge Town"] and it should be recognized as "Southbridge". Also, using "addr:city" works well in my tests.

(09 Mar '22, 18:23) ocabanas

Show the areas produced by the addr:city line.

The are no 2Southbridge Town" objects. https://overpass-turbo.eu/s/1gLY

(09 Mar '22, 19:14) DaveF

Source code available on GitHub .