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

Hi!

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

Carlotta
21449
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 https://www.openstreetmap.org/relation/42609, or rather the linked node https://www.openstreetmap.org/node/4404418359 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.

https://wiki.openstreetmap.org/w/index.php?title=Tag:boundary%3Dadministrative&uselang=en-US 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

mtmail
4.8k1574
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 http://nominatim.org/release-docs/latest/api/Search/ 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

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:

×689
×107
×78
×5
×5

question asked: 01 Apr '20, 13:47

question was seen: 2,896 times

last updated: 01 Apr '20, 15:21

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