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


I have some postcodes and I want to et the following information: city, province and region.

I did the following query using Nominatim: loca = geocode(query = row['CAP'], country_codes = country, addressdetails = True, language = 'it,en')

To retrieve the city I found out that there can be varoius information in the addressdetails: loca.raw['address']['city'], loca.raw['address']['hamlet'], loca.raw['address']['village']. To retrieve the region I found out that the information is stored in loca.raw['address']['state']. For the province I have found the information under loca.raw['address']['county'], but it is not always correct.

I'll make you an example: postcode 47122, it is a city in Italy, province Forlì. When I search this postcode in nominatim.openstreetmap I get this result:

alt text

So my question is: Is this workflow correct or there are better ways to retrieve city, province and region? How can I get a more detailed address that includes all the information I need?

Thanks, Carlotta.

asked 01 Apr '20, 13:47

Carlotta's gravatar image

accept rate: 0%

Yes, that's the approach.

In the response a place admin_level=6 becomes ['address']['county']. The details.php page shows 'province' because the relation, or rather the linked node because Nominatim merges them into one in its database, has a place=province tag. Getting province disabled on the details.php is relative new, I think since last week. shows what admin_level numbers mean in the various countries. In Italy 6 it is provinces.

permanent link

answered 01 Apr '20, 14:02

mtmail's gravatar image

accept rate: 27%

Thanks a lot! So to have the province detail I need to specify boundary=administrative + admin_level=6 in the geocode?

Thanks again, Carlotta.

(01 Apr '20, 14:16) Carlotta

It's not clear which software library you use. Check its documentation or for possible parameters/filters. To get the details about a province you'd need to search for the province name.

(01 Apr '20, 15:17) mtmail

Sorry, I haven't specified that! I am using Geopy Nominatim in python. I tried to search for documentation on it, but I haven't found anything useful yet.

(01 Apr '20, 15:21) Carlotta

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: 01 Apr '20, 13:47

question was seen: 2,629 times

last updated: 01 Apr '20, 15:21

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