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

Hi...can any one plz tell me, how can I get the polygon ID from coordinates for certain towns.Thank you.

asked 02 Jul '13, 18:46

Uma%20Maheswari%20K's gravatar image

Uma Maheswari K
accept rate: 0%

If you want to do such a query by hand, try the following:

go to and type the name of the town in there.

See the results whether you get an entry with a little symbol like this: alt text

Then choose "details" about it and you will see its OSM id.

Be aware: not all towns in the world have a valid boundary relation around.

permanent link

answered 02 Jul '13, 21:02

stephan75's gravatar image

accept rate: 6%

edited 02 Jul '13, 21:04

Hi,I want to get polygon ID for some towns in Canada. '' ,this link only gave me the polygon ID for states in Canada...When I looking for towns it will give town node ID only..How can get polygon ID for towns...Please clear doubt. Thank you.

(04 Jul '13, 07:46) Uma Maheswari K

Could you give some examples of what queries you've tried and what they return?

(04 Jul '13, 09:08) SomeoneElse ♦

Ya,sure I searched for a town named 'Calmar' ( It is situated in Alberta,Canada) It returns the following,


Calmar (Type: place:town, node 1135364356, 15, 0 GOTO)

Alberta (Type: boundary:administrative, relation 391186, 4, 2.03038389612396 GOTO)

Canada (Type: boundary:administrative, relation 1428125, 2, 20.1577291628353 GOTO"

When I click GOTO for Alberta it gives the boundary. But for Calmar it gives a node.I want boundary for Calmar But it returns node only.I want Polygon ID for this town to get that town boundary. Could you plz guide me...?

(04 Jul '13, 11:35) Uma Maheswari K

Some settlements/places may only have been mapped with a node, not a polygon. Since the boundaries of some settlements are vague or ambiguous, some mappers feel this is a less misleading way of showing towns and villages. This means the polygon you're looking for simply may not exist.

(04 Jul '13, 12:38) Jonathan Ben...

Uma, you can try webservices like or to see whether there are already any administartive boundaries around the towns you are looking for.

If is quite possible that not all towns or places in Canada have already boundary relations.

(04 Jul '13, 16:47) stephan75

You can import the data into a PostGIS database (using osm2pgsql for example), then run a query that goes like

select osm_id from planet_osm_polygon 
   boundary='administrative' and
   admin_level='8' and
   ST_CONTAINS(way, ST_TRANSFORM(ST_SETSRID(ST_POINT(my_longitude,my_latitude), 4326), 900913));

A similar query is possible with a database imported for Nominatim use.

permanent link

answered 02 Jul '13, 19:41

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
accept rate: 23%

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 Jul '13, 18:46

question was seen: 7,708 times

last updated: 04 Jul '13, 16:47

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