NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

Hi, OSM crew. I'm newbie here. I try to count each POI nodes around specific GPS coordinates. This is my code for loading node around specific lat and lon using Python

overpass_url = ""
overpass_query = """
out body;
response = requests.get(overpass_url,
                        params={'data': overpass_query})
data = response.json()

From this code, I get every nodes around that specific area. But I have more than 50,000 place to find. I want to know how can I use some variables instead of typing every coordinates in my code.

Moreover, I just want to count every POI node separated by its amenity tag such as 'drinking_water' or 'cafe' but I can't find tag index in data

Thanks for any help.

asked 02 Oct '18, 11:41

Krawan's gravatar image

accept rate: 0%

Your current query is for all nodes, so most of them don't have tags. You probably want to restrict that a bit.

Something like this will only return nodes with an amenity tag or a tourism tag (they don't have to have both):


Generating the query is more a python question, there's lots of ways to do string substitution over there. In Python 3 I tend to use format strings anymore, so you could replace the coordinates in your query with some variables:


Then you'd substitute in the values:


You might also consider using the nwr query operator (along with out center;) instead of node . Then your results will include POIs that are modeled as ways or relations instead of as nodes.

permanent link

answered 02 Oct '18, 21:25

maxerickson's gravatar image

accept rate: 32%

Follow this question

By Email:

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



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "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:


question asked: 02 Oct '18, 11:41

question was seen: 3,513 times

last updated: 02 Oct '18, 21:25

NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum