user2704850
user2704850

Reputation: 11

How to avoid getting different city in return value for zipcodes shared by 2 cities

we are trying to use Google API from CRM system to populate / validate addresses on the cases.

In situations where a zip's post office in different city, the address is returned incorrectly. For e.g. zip 53227 is shared by 2 cities (West Allis and Milwaukee) but post office for that zip is in Milwaukee .

For e.g. --> 8511 West Arthur Avenue, West Allis, WI is a valid address. However, when I search for this address, the returning value gives me Milwaukee (where the post office is located for that zip).

Appreciate if you can help on how to stop getting other city from GOOGLE API.

Thanks in advance.

Regards.

Upvotes: 1

Views: 2672

Answers (2)

Jeffrey
Jeffrey

Reputation: 502

Let's look at the why first. Why would there be two cities for the ZIP code 53227?

Remember that a ZIP code represents a delivery area, not a geo-political area. ZIP codes change at the whim of the US Postal Service. In fact, the USPS owns ZIP codes (as far as you can actually own a number). So, with each ZIP code you get a Servicing Post Office (SPO) and multiple cities. You can also have multiple acceptable names for the same city.

Input: 53227

Output: Milwaukee, Greenfield, New Berlin, and West Allis

Milwaukee is the preferred name (or the SPO) for that ZIP code. Greenfield, New Berlin, and West Allis are all cities whose boundaries are overlapped by the 53227 ZIP code.

Here's a map that shows the city boundaries in the background and the ZIP boundary (approximate, since the USPS doesn't really release ZIP code boundary maps) overlayed. The map came from maptechnica.com.

enter image description here

You can see that the ZIP code is predominantly in West Allis, a little bit in Milwaukee, even less in the northern end of Greenfield, and then just the smallest bit right on the border with New Berlin. Thus all four cities are partially covered by the 53227 ZIP code.

The address: 8511 West Arthur Avenue, West Allis, WI certainly is located within the boundaries of West Allis but it also falls within the 53227 ZIP code whose SPO is in Milwuakee. Thus the only way to determine the correct city would be to have the full address, not just the ZIP code.

As Matt pointed out, googlemaps doesn't do that. That's not their business. Just like the homeless guy at the local gas station who can readily tell you how to get to anywhere in the the area but he can't tell you the name of the street, googlemaps is excellent for showing you where on the map something is but they don't necessarily know all the information about that particular location.

[by the way, I work with Matt at SmartyStreets - though he's smarter than I am]

Upvotes: 0

Matt
Matt

Reputation: 23789

I guess I'll expand my comment into a (partial) answer. I don't know how to use Google's API to return the city name you want. But maybe this will still be helpful. (I work at SmartyStreets, where US addresses are our specialty.)

First, let's look at that ZIP code: 53227. According to a SmartyStreets lookup, it is indeed valid and its Post Office (preferred) city name is Milwaukee. West Allis is a suburb which shares the zone, so you're correct there.

Now on to the actual address. As mentioned in my comment, Google doesn't verify addresses, but rather standardizes them, and puts them on a map where they would exist if they were real. This has many useful applications, but if you're looking for validation, you need a true address validation service. Looking that address up with the homepage demo with LiveAddress yields this result:

Address in West Allis

LiveAddress conforms to rigorous CASS™ specifications, and as such, returns West Allis like you'd expect: not Milwaukee. (This isn't the case with all addresses -- and there are technical reasons for it. But for this address, it happens to work just fine.)

Upvotes: 0

Related Questions