How accurate is the Google Maps API for geocoding UK?

Discussion in 'Google API' started by chuckylefrek, Sep 10, 2008.

  1. #1
    Hi there

    Can anyone confirm if the Google API geocoding for the UK is a bit inaccurate or not?

    If I type a postcode into http://maps.google.co.uk/ then I get the correct exact location.

    However when I use the code below, the latitude and longitude returned seems to be off by about half a mile. I therefore want to know if geocoding uk postcodes and addresses using the google API is not very accurate. If so then can anyone recommend any free or cheap alternatives.

    Essentially my site is a UK accommodation directory. When a logged in member adds an accommodation listing I use the code below to retrieve the longitude and latitude to put in the database.

    
    
    define("MAPS_HOST", "maps.google.co.uk");
    $delay = 0;
    $base_url = "http://" . MAPS_HOST . "/maps/geo?output=csv&key=" . KEY;
    
    $geocode_pending = true;
    
    while ($geocode_pending) {    					
        					
        	$request_url = $base_url . "&q=" .  urlencode($postcode);		  			
    
    $csv = file_get_contents($request_url) or die("url not loading");
    
    $csvSplit = split(",", $csv);
    $status = $csvSplit[0];
    $lat = $csvSplit[2];
    $lng = $csvSplit[3];
    
    if (strcmp($status, "200") == 0) {
    
          // successful geocode
    
         $geocode_pending = false;
         echo "Successful geocode";						
          						
         $lat = $csvSplit[2];
         $lng = $csvSplit[3];
         echo "<br />";
         echo "latitude = " . $lat;
    
         echo "<br />";
         echo "longitude = " . $lng;
    
    
    
    } else if (strcmp($status, "620") == 0) {
    
          	// sent geocodes too fast
          	$delay += 100000;
    
    } else {
          	// failure to geocode
          	$geocode_pending = false;
          	echo "Postcode " . $postcode . " failed to geocoded. ";
          	echo "Received status " . $status . "
    						\n";
    }
    
        	usleep($delay);
      				
    } 
    
    
    
    
    Code (markup):
     
    chuckylefrek, Sep 10, 2008 IP
  2. kewlchat

    kewlchat Well-Known Member

    Messages:
    1,779
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    110
    #2
    Im pretty sure its very accurate, they would be getting bad publicity if it wasnt it..
     
    kewlchat, Sep 11, 2008 IP
  3. Andy Peters

    Andy Peters Peon

    Messages:
    430
    Likes Received:
    22
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Not true.
    Google is accurate for http://maps.google.co.uk but due to licensing issues with the royal mail, the geocoding of postcodes in the maps API is not very accurate at all. There's nothing they can do about it, royal mail won't really release the data. As far as i know the API geocoding is only done on the first part of the postcode, which means it's out usually by a mile or so.
    The best thing to do is geocode by address rather than postcode. Typing an exact address will be 100% accurate.
     
    Andy Peters, Sep 25, 2008 IP