Google Distance Matrix API substituting address that isn't even close - google-maps

When I search for '160 Trek Ln, Redding, CA 96003', the Distance Matrix changes my search to 'Bechelli Ln at Hartnell Ave, Redding, CA 96002, USA'. I know that '160 Trek Ln, Redding, CA 96003' doesn't exist yet in Google Maps, but changing the address to something else completely different is definitely not what I want. Getting some kind of error 'Address not found' or something would be better.
Any help would be greatly appreciated.

"Internally Distance Matrix uses Geocoding to resolve the address to coordinate. It will try to get best match even for non-existing address, in your case it gives partial match. I believe there is no way to change this behavior of service. If you know exact coordinate of your address use it instead of address string. In this case Distance Matrix will snap to nearest road directly without geocoding step and you may get better results." – xomena Aug 29 at 20:48

Related

Google maps returning two different routes

I am surprised when I am finding the directions between two locations on google maps(maps.google.co.in) one using LAT, LNG, and the other one using the google suggested name. The routes returned are different.
Origin Address - 161 Keltner Ave, Spartanburg, SC 29302, USA.
Destination latitude and longitude - 35.554627, -82.853629
Link for address to address - https://www.google.co.in/maps/dir/161+Keltner+Ave,+Spartanburg,+SC+29302,+USA/769+Champion+Drive,+Canton,+NC,+USA/#35.2324107,-82.6430623,10z/data=!3m1!4b1!4m14!4m13!1m5!1m1!1s0x88579ff345067667:0x5c96ddb575753f29!2m2!1d-81.8723738!2d34.9216748!1m5!1m1!1s0x88598319df45a533:0xe6a9cc5fe0824b95!2m2!1d-82.853377!2d35.5548676!3e0
Link for address to lat-lng - https://www.google.co.in/maps/dir/161+Keltner+Ave,+Spartanburg,+SC+29302,+USA/35.554627,+-82.853629/#35.2321726,-82.404746,9z/data=!3m1!4b1!4m12!4m11!1m5!1m1!1s0x88579ff345067667:0x5c96ddb575753f29!2m2!1d-81.8723738!2d34.9216748!1m3!2m2!1d-82.853629!2d35.554627!3e0
Why is there so much difference? Am I missing something?
I can't make out much of a difference in the two routes. This is the address to address route as I get it from your link:
This is the route I get from your address to lat/long link:
The only significant difference is the end because the lat/long isn't 100% at the address and it appears you need to take a bit of a detour in the latter case:
The measured difference is about 223 m:

autocomplete to return results within a radius

In my google maps autocomplete server side query, i'm trying to return results around or near a latitude and longitude, I've tried this so far
https://maps.googleapis.com/maps/api/place/autocomplete/json?key=<<KEY>>&types=geocode&sensor=true&language=en&location=40.64131109999999%2C-73.77813909999998&strictBounds=true&radius=10&input=london
WHERE 40.64131109999999%2C-73.77813909999998 is the latitude and longitude of JFK - John F. Kennedy International Airport.
But when the search string is london, results still show. Any idea how to limit results within a certain radius / boundary or country? Thanks
Here are my findings on your URL request:
You have included strictBounds=true which is incorrect since parameters are case sensitive hence it will be omitted in the request. It should be strictbounds instead.
You also do not need the =true because adding the parameter strictbounds is enough to restrict the places returned within the defined location and radius.
The value of radius that you have included is too small (10) which may lead to ZERO_RESULTS
You may try this request instead:
https://maps.googleapis.com/maps/api/place/autocomplete/json?input=london&location=40.64131109999999,-73.77813909999998&radius=10000&components=country:US&strictbounds&key=YOUR_API_KEY

Power BI: Latitude/Longitude points to total different places

I am starting with PBI Desktop and want to place my customers on a map.
I have a view from SQL Server with Postcode, City, Latitude, Longitude, for example:
1010, Wien, 48.2073308, 16.373384
when I put lat/Long in Google maps it is perfectly in the heart of Vienna/Austria, correct.
In PBI it is somewhere near Memphis/USA.
On top of that, if I turn the coordination the other way round, Long/lat =48.2073308, 16.373384 I find a spot in the Dessert of Yemenia and not Memphis.
Any idea, whats wrong there??
Thanks
Michael
I think I got it to work.
Lan/lon is not enough, you must add a City or post code.
I do not know why, because GPS coordinates are unique but without a City they can not be assigned correct obviously.
Michael

Lat Lng to Makani Converter

Is there anyone knows how to convert a latitude and longitude coordinate to a Makani Code?
Makani is the new addressing system being implemented in Dubai. I wonder how they convert coordinate points to 10 digit unique code called Makani.
see this Makani Website
Just for your information, the Makani number IS based on a standard position system, the MGRS (Millitary Grid Reference System), so the conversion is straight forward enough, or so you would expect.
The problem is the implementation, you need to be accurate to 1m with the selected Co-Ordinates for where the guys at Makani decided to pick, or else your 'converted' Makani number WILL NOT be recognized by the system.
There are actually ways around this however; take for example....
Arabian Ranches, Al Mahra, Villa 124 (Street 4 Villa 12)
Makani Number: 26038 71480
MGRS Reference: 40R CN 26038 71480
Just drop onto Google Maps, select 'somewhere' on this Villa, and get the Co-ordinates...
Lat/Long: 25.049095, 55.275528
Convert this to Military Grid you get...
MGRS Reference: 40R CN 26036 71492
(Just to clarify CN is a 100Km Square Grid and the numbers are X,Y Meter References within that grid, so physically, my Lat/Lon Pick was actually only 2M West [26038-26036] and 12M North [71492-71480] of the Makani Guys Pick, unfortunately, the accuracy makes the error dramatic)
Goto Makani and enter 26036 71492, and you get a 'No Data Found' Error However; Makani DOES let you search by MGRS, so if you enter the complete '40R CN 26036 71492' into the Makani search, it shows the correct location, with the highlighted Makani Pin.
Hope this helps...
I know it's late for answering the problem now, but I think the solution is worth it.
After googling the problem for quite some time, at last, found some solution which is practical and works.
here it is,
You can use this
Dubai-Makani-No-Api , It's
Javascript Module for getting details about Makani Numbers.
OR
the government of Dubai provides a Makani Public Web Service Access API Given
Here and Here
you can view the API for a more sophisticated requirement.

Picking the most accurate geocode

I'm using http://maps.google.com/maps/geo? web service to geocode some addresses.
The problem I have is that a fuller address doesn't necessarily give a more accurate geocode.
e.g passing in Llantysilio, Denbighshire, UK is far more accurate than Llantysilio, Llangollen, Denbighshire, UK
The Accuracy attribute in the XML doesn't seem very helpful in deciding which address to pick.
How have other people dealt with this issue? Is there a good way to pick the best geocode that works most/all of the time?
*edit
A bit of extra info - when I put in the fuller address the first line of the address is ignored and the geocoder jumps to a different, but exact, address which is a central street located in the extra line added to the address. In this example, it picks Castle Street in the middle llangollen, seemingly disregarding Llantysilio.
Edit by kdgregory: here are the two API requests that I used (missing API key doesn't seem to be an issue):
http://maps.google.com/maps/geo?q=Llantysilio,+Denbighshire,+UK&sensor=false&output=xml
http://maps.google.com/maps/geo?q=Llantysilio,Llangollen,++Denbighshire,+UK&sensor=false&output=xml
You have to interpret the accuracy my friend. There are usually 2 parts to an accuracy, first the address macthing. The second part is the important part. You can geocode something to a accuracy level of the United States, or a city level, zipcode centroid, street interpolated level or an actual parcel precision level. The first example has a 4 and the second is 9. For this service higher is better.
Accuracy Value Description
0 Unknown accuracy.
1 Country level accuracy.
2 Region (state, province, prefecture, etc.) level accuracy.
3 Sub-region (county, municipality, etc.) level accuracy.
4 Town (city, village) level accuracy.
5 Post code (zip code) level accuracy.
6 Street level accuracy.
7 Intersection level accuracy.
8 Address level accuracy.
9 Premise (building name, property name, shopping center, etc.) level accuracy.
It's probably good to note that Google does not follow the XAL specs, but rather implements them in a subset.
So, this means that you won't necessarily be able to do:
place.AddressDetails.Country.AdministrativeArea.Locality.LocalityName
place.AddressDetails.Country.AdministrativeArea.AdministrativeAreaName
place.AddressDetails.Country.CountryName
Because a country and sub-locality may be provided while a administrative area is not.
The data that is returned is identified with an accuracy gauge that gives you a relative idea of what you can expect for data. So, you can store objects and chop off parts of the full address using this variable and try to geocode in such a fashion - It's not recommended though.
Typically, a full address is (without the thoroughfare) is a good way of finding the general location. You can use some of the weighted-preferential logic Google provides to refine the address.
E.g. Use the setViewPort or setCountryCode to give your searches a bit more accuracy.
Remember, Geocoding is not a science. You can't expect consistent results.
A geocode response.Placemark[0] via gmap you can check what you got, and take the level or try again. I chose default in the order
place.AddressDetails.Country.AdministrativeArea.Locality.LocalityName
place.AddressDetails.Country.AdministrativeArea.AdministrativeAreaName
place.AddressDetails.Country.CountryName
It could be more logically named as seen above. gmaps 3 works somewhat incompatible with v2.
You can try a very ugly hack which consists in geocoding your full adresse and all subsets of the words your adress contains, you get a lot of geocodes that you use to get the adresses related to them with reverse geocoding tool.
Once you have plenty of adresses you compare them with the one you first gave, then you take the most accurate geocode...
Many requests, lot of iteration growing with each word you add to your adress, well an ugly work but can be fun to make some statistics ^^
In the end I concluded that there are far too many weird blips in address consistency with google's geocoding webservice in the UK, but eventually managed to figure out a way of using postcodes instead, which is far more accurate: how it's done