views:

1523

answers:

5

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
A: 

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.

LarsOn
A: 

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 ^^

Ar3s
+1  A: 

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.

Justin Van Horne
+3  A: 

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.

A: 

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

wheresrhys