Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making sense of Google Geocoding API results

I'm using Google's Geocoding API to process free-form address data and am trying to make sense of the results (subpremise, administrative_area_level_2, etc.). At this point I'm only interested in addresses in the US, and would like to format the results as a street address, city, and state code. The state code seems straightforward (administrative_area_level_1), but the others are more vague. Is city locality or sublocality or both or even more? The street address itself seems like it could be any number of combinations of the other fields.

Ideally, I'd like to just take the formatted_address, strip off the city, state, zip, and country code, and keep what is left as my "street address". Are there any guidelines or recommendations for handling all these fields, at least for the majority of cases (regular addresses, addresses with unit numbers, etc.)?

like image 460
jrdioko Avatar asked Jun 06 '11 22:06

jrdioko


People also ask

Is Google geolocation API accurate?

While HTML5 geolocation provides the latitude and longitude, the Google Maps Geocoding API can convert those into a complex structure of address components. The combination of the two gives us door-level accuracy in most cases.

What happens when you exceed the Google geocoding API rate limit py4e?

According to Google's API Usage and Billing page, there is a limit of 50 requests per second. If you exceed this amount, subsequent requests to the API will fail with the OVER_DAILY_LIMIT or OVER_QUERY_LIMIT status code and the geocoded data will not be returned.

What does geocode return?

The geocoder does its best to provide a street address that is readable for both the user and locals. To achieve that goal, it returns street addresses in the local language, transliterated to a script readable by the user if necessary, observing the preferred language.

How do I use Google geocode API?

Enable Geocoding API In your Google Cloud Platform Console, go to APIs & Services → Dashboard → Enable APIs & Services at the top and choose Maps JavaScript API from the API Library. This will open up the Maps JavaScript API page and Enable it.


3 Answers

  • Street address is street_number and route
  • City is locality
  • State is administrative_area_level_1
  • ZIP is postal_code
  • Country is country

Note that Google ignores any kind of unit number (e.g. 'Apt 13A'). You'll have to add that back in yourself.

Running a sample of your data through the geocoder and checking the results manually should confirm that you're getting what you need.

like image 82
Sean Avatar answered Oct 20 '22 23:10

Sean


The documentation seems to cover what the various fields mean quite clearly.

You havent said what language you are working in, but I think this will help.

like image 1
expelledboy Avatar answered Oct 21 '22 01:10

expelledboy


I am doing reverse geocoding on Nearlots.com in the search pages. Basically, the user drops a marker somewhere on the map and I print an address in a search box.

I am simply printing 'formatted_address' and giving up if it's not there. This will give you something like this: "275-291 Bedford Ave, Brooklyn, NY 11211, USA". This is more than sufficient - you can always strip out the USA at the end.

like image 1
rndapology Avatar answered Oct 21 '22 01:10

rndapology