5

When a user of my web site enters an address, he often does it like this:

street_number street what_he_thinks_is_the_locality

When I store it or display it, I need to show it better like this:

street_number street, true_locality

I use the geocoder service to extract the address components so that I can format it correctly. I rely on the type of the component to find the locality and I expect "locality", "sublocality" or "administrative_area_level_3". But today I saw a user enter an address and the locality was returned as the {"neighborhood", "political"} type.

What is neighborhood exactly? When is it returned? Was it returned because the google API detected that the user was at a certain "near location" from the result? When this type is returned, should I include the next address component to remove all ambiguities?

Thanks

1 Answer 1

10

A "neighborhood" is generally a small community within a city (often times a housing development). It is different from a "sublocality" in that it usually is not an administrative boundary.

  • Example 1: SoHo (neighborhood), Manhattan (sublocality/borough), New York (locality/city), NY (administrative_area_level_1/state)
  • Example 2: Cap-Saint-Jacques (neighborhood), Pierrefonds-Roxboro (sublocality/borough), Montreal (locality/city), QC (administrative_area_level_1/province)

Google's geocoder is not perfect. It may contain errors, such as Bay Ridge in the Brooklyn borough of NYC for which Google returns Manhattan as the sublocality. Similarly, in example 2 above Pierrefonds is listed as the sublocality, rather than Pierrefonds-Roxboro.

The geocoder is also incomplete at times. Zip code 02130 is in Boston, yet the geocoder does not return a "locality". It only returns the Jamaica Plain neighborhood. However, if you add Jaimaica Plain to the Zip code, then it does return the locality (a possible workaround, though it requires two requests).

What you likely experienced is this later case. It's not clear what conditions trigger it. You'll need to account for the fact that the results are not always complete.

1
  • 1
    Google must have fixed that because it's now displaying Brooklyn as the sublocality.
    – Chris
    Commented Dec 9, 2012 at 8:29

Not the answer you're looking for? Browse other questions tagged or ask your own question.