Geocoder oddity

45 views
Skip to first unread message

Marcelo

unread,
Nov 10, 2011, 9:59:56 AM11/10/11
to Google Maps JavaScript API v3
Hello,

I am geocoding a bunch of addresses and I encountered something odd.
The addresses are schools and my script always checks the returned zip
code before updating the database.

In some cases, if I send a street address, I get a ROOFTOP result but
with a different zip code than the one I sent, while if I send the
name of the school without an address then I get an APPROXIMATE result
with the correct zip code.
The returned lat/lon is identical in both cases.

Example:

Street address -> I get a ROOFTOP result but with a different zip
code:
----------------------------------------------------------
3510 N YARBROUGH DR, EL PASO, 79925, TX
http://maps.googleapis.com/maps/api/geocode/xml?sensor=false&address=3510%20N%20YARBROUGH%20DR,%20EL%20PASO,%2079925,%20TX
----------------------------------------------------------
<GeocodeResponse>
<status>OK</status>
<result>
<type>street_address</type>
<formatted_address>3510 N Yarbrough Dr, El Paso, TX 79935, USA</
formatted_address>
<address_component>
<long_name>3510</long_name>

.. SNIP ...

<type>country</type>
<type>political</type>
</address_component>
<address_component>
<long_name>79935</long_name>
<short_name>79935</short_name>
<type>postal_code</type>

</address_component>
<geometry>
<location>
<lat>31.7961830</lat>
<lng>-106.3314190</lng>
</location>
<location_type>ROOFTOP</location_type>
----------------------------------------------------------


School name -> APPROXIMATE result with the correct zip code:
----------------------------------------------------------
NEW WORLD MONTESSORI SCHOOL, TX
http://maps.googleapis.com/maps/api/geocode/xml?sensor=false&address=NEW%20WORLD%20MONTESSORI%20SCHOOL,%20TX
----------------------------------------------------------
<GeocodeResponse>
<status>OK</status>
<result>
<type>point_of_interest</type>
<type>establishment</type>
<formatted_address>New World Montessori School, 3510 N Yarbrough Dr,
El Paso, TX 79925-1626, USA</formatted_address>
<address_component>

.. SNIP ..

<type>country</type>
<type>political</type>
</address_component>
<address_component>
<long_name>79925-1626</long_name>
<short_name>79925-1626</short_name>
<type>postal_code</type>

</address_component>
<geometry>
<location>
<lat>31.7961830</lat>
<lng>-106.3314190</lng>
</location>
<location_type>APPROXIMATE</location_type>
----------------------------------------------------------


Does anyone care to comment before I post to the issue tracker?


--
Marcelo - http://maps.forum.nu
--

Rossko

unread,
Nov 10, 2011, 10:56:20 AM11/10/11
to Google Maps JavaScript API v3
> Does anyone care to comment before I post to the issue tracker?

Post what? If you geocode a postal address, you get a result. If you
geocode a business/establishment name, you may or may not get some
result from the address geocoder (in your case you do). In both cases
the geocoder provides a lat/long, that is what geocoders do.
Geocoders are not so good for zip-code lookup, if that is what you are
trying to do, it is the wrong tool. What is the problem?

Marcelo

unread,
Nov 10, 2011, 11:13:49 AM11/10/11
to Google Maps JavaScript API v3
The problem is that any one address has one, and only one zip code,
but the geocoder is returning one address with two different zip
codes, depending on how you query it.

In one case it returns:
3510 N Yarbrough Dr, El Paso, TX 79935, USA

and in the other:
3510 N Yarbrough Dr, El Paso, TX 79925-1626, USA

--
Marcelo - http://maps.forum.nu
--


Andrew Leach

unread,
Nov 10, 2011, 11:36:54 AM11/10/11
to google-map...@googlegroups.com
On 10 November 2011 16:13, Marcelo <marce...@hotmail.com> wrote:
> The problem is that any one address has one, and only one zip code,
> but the geocoder is returning one address with two different zip
> codes, depending on how you query it.
>
> In one case it returns:
> 3510 N Yarbrough Dr, El Paso, TX 79935, USA
>
> and in the other:
> 3510 N Yarbrough Dr, El Paso, TX 79925-1626, USA

Hi Marcelo. Long time and all that.

It appears the geocoder is doing two things: geocoding an address (and
getting the zipcode wrong) and finding a business (where its
associated details probably come from a different dataset and are
correct).

It's certainly worth reporting that if you provide an address with the
correct zipcode, the results show a different, incorrect, one.
Something similar happened with UK postcodes once.

However Rossko is right: a geocoder turns an address into coordinates
(you know that!), so it's doing its job if the coordinates are
acceptably correct.

Marcelo

unread,
Nov 10, 2011, 11:56:19 AM11/10/11
to Google Maps JavaScript API v3
On Nov 10, 8:36 am, Andrew Leach <andrew.leac...@gmail.com> wrote:
>
> However Rossko is right: a geocoder turns an address into coordinates
> (you know that!), so it's doing its job if the coordinates are
> acceptably correct.

Hi Andrew,
Good to "see" you too. :-)

"turns an address into coordinates" or turns coordinates into an
address, so if we reverse geocode the returned coordinates, are we
getting the correct zip code in the returned address?

http://maps.googleapis.com/maps/api/geocode/xml?sensor=false&latlng=31.7961830,-106.3314190
Returns zip code 79935

I'll post to the issue tracker.
By the way, I have a few hundred similar cases.

JKurtock

unread,
Nov 10, 2011, 12:05:39 PM11/10/11
to Google Maps JavaScript API v3
I can only add that "wrong" zip codes are not too surprising to me.
While it is true that there is only one zip code per MAILING address,
that's only because the USPS says so, not because of some immutable
truth of mapping. While there are those who offer "maps" of zip codes,
they are actually approximate at the edges because the Post Office
assigns the zip code for the convenience of delivery, not to make
contiguous maps.

I suspect that Google uses a map-like solution to find zip codes vs.
addresses, and a data-base solution to find zip codes from place
names. The map-like solution will have problems at the edges.

Another place I have seen this is in the County returned by the
geoCoder. In the US, cities don't extend over County borders, but the
"map-like" borders used by Google (you can display them in Google
Earth, if you wish) are simplified and don't always exactly follow the
wiggles of a city border. Addresses on the edge of town may geocode
to the wrong county.

So, as others have said, the geoCoder excels at returning lat-lng.
The other details are gravy, but are not correct every time.

Last, if you cared about the zip code (it doesn't sound like you do),
the Post Office itself has a limited API that will return the 9-digit
zip code for any valid address. And, by definition, they are ALWAYS
correct.

- Jeff

On Nov 10, 8:36 am, Andrew Leach <andrew.leac...@gmail.com> wrote:

Marcelo

unread,
Nov 10, 2011, 12:19:46 PM11/10/11
to Google Maps JavaScript API v3
On Nov 10, 9:05 am, JKurtock <jkurt...@gmail.com> wrote:
>
> Last, if you cared about the zip code (it doesn't sound like you do),
> the Post Office itself has a limited API that will return the 9-digit
> zip code for any valid address.  And, by definition, they are ALWAYS
> correct.
>

Hi Jeff,

I do care about the zip code because I use it to verify the result
before updating my database with the coordinates.
I am geocoding a list of schools in the US, but in some cases, the
returned result was in Canada, so I discarded it.
It is because of this zip code check that I became aware of the issue.

I posted it to the issue tracker:
http://code.google.com/p/gmaps-api-issues/issues/detail?id=3731

--
Marcelo - http://maps.forum.nu
--





MymsMan

unread,
Nov 10, 2011, 2:33:34 PM11/10/11
to google-map...@googlegroups.com
What zip code is returned if you do a reverse geocode on the lat long value - it would be unfortunate if that returned the wrong zip code.

It does return 3510 N Yarbrough Dr, El Paso, TX 79935, USA
Reply all
Reply to author
Forward
0 new messages