Best practice for AKA addresses - google-maps

Using geocode api to get location data and full address details from an address string. This address string might include the property name, city and state or an actual street address. Been using for years with good results. Some buildings, particularly in cities like NY, use multiple addresses. Although the maps pin is in the same location, these equivalents return different coordinates and are not equivalent. Willis Tower, Chicago IL, is the same as 233 S Wacker Dr, Chicago, IL...but not exactly.
Queries are simple...In python...
GMAPS = googlemaps.Client(key=settings.MAPS_TOKEN)
res =GMAPS.geocode(address text string with building name or street address)
with the res, I pull out city,state,county,long,lat...
Is there a technique for identifying equivalence for buildings that have one structure, but multiple possible addresses

Related

Different placeID gives the same address information

Below two placeID's gives the same address.
1. EicyMDEgU291dGggTG93cnkgU3RyZWV0LCBTbXlybmEsIFROLCBVU0EiMRIvChQKEgm7_A4lPAxkiBEptR2cpqTb1xDJASoUChIJT4MxvQIMZIgRENDVZ6XiGTc
2. ChIJBbYyJDwMZIgR1TtBueaig5w
PlaceID1 was returned when the address searched using the autocomplete was " 201 South Lowry Street" and PlaceID2 was returned when the address searched using the autocomplete was " Goodwill Industries of Middle Tennessee 201 South Lowry Street".
Even though the above addresses are different, the place details API gives the same address information.
https://maps.googleapis.com/maps/api/place/details/json?place_id=EicyMDEgU291dGggTG93cnkgU3RyZWV0LCBTbXlybmEsIFROLCBVU0EiMRIvChQKEgm7_A4lPAxkiBEptR2cpqTb1xDJASoUChIJT4MxvQIMZIgRENDVZ6XiGTc&key=API_KEY
https://maps.googleapis.com/maps/api/place/details/json?place_id=ChIJBbYyJDwMZIgR1TtBueaig5w&key=API_KEY
Question :
1. Why is the same address which is of the street returned for two different placeID's?
2. The location returned by places Details API is correct but the address is of the street.
Below are few more examples where I observed same scenarios. Could you please brief on the below mentioned examples also?
PlaceID : ChIJZ2fZgcNVZIgRRY-uzGW9IBc and ChIJi15Hp8RVZIgRojWuKm_aG3M returned the same address as "2008 Memorial Boulevard Springfield Tennessee United States 37172", but the straight line distance between the two places is approximately 154 meters.
PlaceID : EiBBbm5leCBBdmVudWUsIE5hc2h2aWxsZSwgVE4sIFVTQSIuKiwKFAoSCd8ldk-TYWSIEZbufa-nQvmSEhQKEgk9kOsTMuxkiBGg2umh0Lk_fQ and ChIJ9ynrOIthZIgR-_7_cmwzeXo returned the same address as "3736, Annex Avenue Nashville Tennessee 37209" , but the straight line distance between the two places is approximately 6.92 meters.
PlaceID : ChIJTZvXpuJ7ZIgR8GqA7eDu5oY and ChIJ3ZUKweJ7ZIgRBjj8OqdMm5E returned the same address as "1777, Galleria Boulevard Franklin Tennessee 37067 " , but the straight line distance between the two places is approximately 12.24 meters.
PlaceID : EicyMDEgU291dGggTG93cnkgU3RyZWV0LCBTbXlybmEsIFROLCBVU0EiMRIvChQKEgm7_A4lPAxkiBEptR2cpqTb1xDJASoUChIJT4MxvQIMZIgRENDVZ6XiGTc and ChIJBbYyJDwMZIgR1TtBueaig5w returned the same address as "201 S Lowry St, Smyrna, TN 37167, United States " , but the straight line distance between the two places is approximately 97 meters.
Please note that it's possible for each place or feature to have similar addresses. This is why the Places API used Place IDs instead to uniquely identify the place/feature. As per this doc:
Place IDs uniquely identify a place in the Google Places database and
on Google Maps.
Below is my investigation on the addresses you have mentioned:
The place ID, ChIJZ2fZgcNVZIgRRY-uzGW9IBc, is of type, premise. As per the Address Types doc here:
Premise indicates a named location, usually a building or collection
of buildings with a common name.
If you think that a collection of building should not have the same address as the Place ID, ChIJi15Hp8RVZIgRojWuKm_aG3M, then I suggest that you report this Maps Data issue. (I'll put some more details on how to report Maps Data issues below)
The address returned for EiBBbm5leCBBdmV...iBGg2umh0Lk_fQ is an address of a route (Annex Ave, Nashville, TN 37209, USA), which is not the same as the the second Place ID's (ChIJ9ynrOIthZIgR-_7_cmwzeXo) address (3734 Annex Ave, Nashville, TN 37209, USA).
For the Item #3, what I can see is that the place ChIJTZvXpuJ7ZIgR8GqA7eDu5oY is a street_address while the other feature (ChIJ3ZUKweJ7ZIgRBjj8OqdMm5E) is a point_of_interest. These two features does not seem to be related so I believe that this is another Maps Data issue which can also be reported.
The feature, EicyMDEgU29...ENDVZ6XiGTc, on the other hand appears to be an inferred street address from a range of addresses. While the place, ChIJBbYyJDwMZIgR1TtBueaig5w, is the actual point_of_interest that's on that same street address. Note that the point of interest may close or move to a new location, but, the street address most likely won't change.
For Maps Data issues, this can be reported using the "Report a
Problem" or "Send feedback" link on the bottom right corner on
maps.google.com or in the Google Maps for Mobile Application. To learn
more, please see this guide. But for Maps Data that are added
using Google My Business, this can be modified directly by the
business owners themselves on their Google My Business account.
I hope this helps!

Google Maps Autocomplete doesn't include postcodes in address search

For my current project, I have an address lookup for the user to enter an address. In its default state, its results are too ambiguous, and the lookup returns all locations even if it isn't actually an address (eg some of the locations in the list are an entire city or region).
Adding types: ['address'] to the query has solved this; Google now only responds with actual addresses instead of ambiguous regions, however this has lost us the ability to search via postcode, as these two fiddles demonstrate:
http://jsfiddle.net/yj6qvpsg/2/ will list entire cities and regions (bad), but you can still search for an address with a UK postcode (good).
http://jsfiddle.net/yj6qvpsg/1/ will only list addresses (good), but won't search UK postcodes (bad).
How do we get the best of both worlds? I tried playing around with eg, types: ['address', 'postal_code'], but had no luck...
So it turns out that it's only really in the UK that postcodes are tied to physical addresses at street level (you can literally give the house number and postcode as a complete and valid address), while in the rest of Europe a postcode represents a whole region, hence Google considers postcodes as regions throughout.
Maybe one day they'll make an exception for the UK, but in the mean time an alternative if you really need this feature is probably to look at something like: https://getaddress.io/ which might suck if like us your entire data structure is built to match Google's
This came up as the top result for this question, but is massively outdated.
So for anyone looking for a more in-depth search, set Google's Autocomplete to geocode and you can search by:
Street name
District
Town
City
Postcode
Ace!

Regions of England in Google Maps API

I have a list of latitude/longitude which point to some cities in England.
For each of these coordinates I want to get the region they belong to.
By region, I mean one of these: https://en.wikipedia.org/wiki/Regions_of_England
For instance: For coordinates (53.38112, -1.47008), ie. Sheffield, I need to find Yorkshire and the Humber.
To achieve this, I tried to use Google Reverse Geocoding API:
https://maps.googleapis.com/maps/api/geocode/json?latlng=53.38112,-1.47008&key=
Google then tells me that:
country is United Kingdom
administrative_area_level_1 is England, which is a State (or kind of)
administrative_area_level_2 is South Yorkshire, which is a County
administrative_area_level_3 is Sheffield District, which is a District
So Google returns me the correct State, County and District. However, Region is missing.
Is there any way to obtain it?
Looking at the documentation I don't think the Google API returns such information.
An alternative way to get round this would be to build a list of which counties belong in which of the 9 regions and then look up the region based on the county name. Obviously, this would be a bit of work on your part putting all the county names into a list.
While this doesn't directly answer your query, you could use a set of polygons which trace the regions and a point in polygon algorithm (this example is in PHP but the algorithm exists in many languages) which would allow you to check which of the regions any latitude and longitude is in

Is there a numeric road identifier in google maps?

I'm looking for a way to identify roads or streets on google maps.
I don't need the road name, just an identifier for a road. And I don't really care if GPS coordinate is really on the road as long as the results are consistent.
I need this in order to determine if two GPS coordinates are on the same road.
Now I know I can compare the road name between the two coordinates using geocoder but In some cases the road name is null, and I actually don't care about the name itself.
Is there any road ID that I can get using a geocoder ?
What do you mean by the 'same road'?
A road can have many different names and designations at the same time and over its length.
Consider Route 66 do you want to be considered to be on the same road if you are on the same road if your two locations are on route 66 near Los Angeles and Chicago or is it a series of different roads as wends its way through the cities en-route?
Should a road have a different id if has an arbitrary name change as it goes round a bend or crosses from one town to the next?

How to map google Geocoding API results to simple City, Region, Country

I have some markers on a map and when the user click them I use the google geocoder to get the address information. The issue is the format that Google returns this data. I want to display the address in a consistent format such as
Vancouver, British Columbia, Canada
Seattle, Washington, United States
Sydney, New South Wales, Australia
does any one know a simple way to parse this data so I end up with some nice simple json like
{"city":"Vancouver", "region":"British Columbia", "country":"Canada"}
Thanks.
Oh man, the days when I thought political geography was this simple were sweeter days. If Google could return data like this, they surely would. Instead you get a mess of locality, sublocality, administrative_area_level_*, country, etc.
To illustrate this, consider the following:
http://maps.googleapis.com/maps/api/geocode/json?address=11215&sensor=false
http://maps.googleapis.com/maps/api/geocode/json?address=10010&sensor=false
For Manhattan, you're in okay shape. You get the borough (Manhattan), the city (New York), the county (New York), and the state (New York). For Brooklyn, things aren't so clean. You get the borough (Brooklyn), the county (Kings), and the state (New York).
Now if you go a little ways out onto Long Island, you get more fun:
http://maps.googleapis.com/maps/api/geocode/json?address=40.723464,%20-73.716282&sensor=false
In this case you get the village (Floral Park), the town (Hempstead), the county (Nassau), and the state (New York), but everything is kind of muddled up.
This is the variation within 20 miles in one state. If you move out of that, you can count on even less. In the UK, what most of what we'd want to see as London, will be some smaller borough of Greater London.
Google provides a deep and rich taxonomy to deal with this variation, but you will still need to apply your own rules to make sense of it (often at the state by state and country by country level)