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, 10:24

ocabanas's gravatar image

ocabanas
11113
accept rate: 0%

edited 09 Mar, 18:20


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;
permanent link

answered 09 Mar, 18:03

DaveF's gravatar image

DaveF
3.0k7793127
accept rate: 15%

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, 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, 19:14) DaveF
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×215

question asked: 09 Mar, 10:24

question was seen: 401 times

last updated: 09 Mar, 19:41

powered by OSQA