I'm not sure if I should have posted this under programming - but most google map posts seem to be here. I need to be able to generate a Google Map using a UK postcode. Does anyone know of a UK geocode resource that will help me convert / find the lat and long values I need to pass to GM?
yes, thank you red repper for suggesting "google it" - I did for half an hour before posting here. Get a life.
TOPS to the rescue... http://www.evoxfacilities.co.uk/evox7.htm http://www.graticule.com/data/uk/pcdata.html Even for free... http://www.jibble.org/ukpostcodes/ How do you like that, Stuw?!
We have a huge amount of google maps on our site and all the postcode lookups are done with postcodeanywhere. I have a php script if anyone wants it.
I forgot to mention that dave487 came to the rescue. I had found postcodeanywhere.co.uk whilst googling around, but had missed the key thing I was looking for - a per conversion rate. Not an annual fee. Thanks for pointing that out. I also found jibble - but it seemed too vague for what I wanted to use it for.
Here you are TOPS, enter your postcode into these, cost is about 4p per lookup. http://www.noblemarine.co.uk/repairers.php3 http://www.noblemarine.co.uk/clubfinder.php3
I can't seem to find a way to get the co-ordinates for google maps from a postcode without a double hit using postcodeanywhere. It seems to get the lat / long I need to pass a location id, and I need to get the location id from passing a postcode? If you could pm your code, or post the method you use that would be a great help. Appreciate your time on this. Stuw
global $ACCOUNTCODE,$LICENSEKEY; $ACCOUNTCODE = "xxxxxxxxx"; $LICENSEKEY = "yyyyyyyyyyyy"; $OriginPostcode = @$_GET['postcode'] ; $sURL = "http://services.postcodeanywhere.co.uk/recordset.aspx?"; $sURL .= "account_code=" . urlencode($ACCOUNTCODE); $sURL .= "&license_code=" . urlencode($LICENSEKEY); $sURL .= "&action=nearest"; $sURL .= "&origin=" . urlencode($OriginPostcode); $sURL .= "&destination=" . urlencode($OriginPostcode); $ContentsXXX=file("$sURL"); foreach ($ContentsXXX as $line_num => $line) { if (strpos($line,"<z:row")!==false) { $Contents[]= $line; } } for ($i=0;$i<count($Contents);$i++) { $Contents[$i]=ltrim(rtrim($Contents[$i])); $Contents[$i]=str_replace("\"","",$Contents[$i]); $breakapart=explode(" ",$Contents[$i]); // convert the results into $variables foreach ($breakapart as $value){ list($k,$v)=explode("=",$value); ${$k}=$v; } // end foreach // coordinates are now saved as Easting: $grid_east_m and //Northing: $grid_north_m and $latitude $longitude PHP: This passes a postcode to postcodeanywhere and returns the coordinates. To use this in a find nearest script you need a database on your server with all your locations stored with their lat,long,easting and northing (email an excel file of your locations to postcode anywhere and they will populate these values for you). Let me know if you need a script to sort the results by distance.......
4p sounds expensive. I enquired before for acquiring such a database and it's about 200 quid. That way you don't rely on any 3d parties, own the software and don't get bills when your application gets popular. If you stick to postcode outcode (the first part) you only need about 1800 records so the database is fairly small and inexpensive.
The problem is that postcodes change all the time. I recently moved to a newly built house and trying to arrange all the insurance & utilities was a nightmare as every website and call centre will only help people with a valid postcode. I had to wait weeks in some cases for their postcode databases to update before they could help me (I had to contact Royal Mail to ask them to update the database). So I would be very annoyed if a site did not have my postcode and a search script failed bacause of it. Also you need exact lats and longs to pinpoint the locations to put on a map - this is not available if you only use the outcode bit. Credits are cheaper in bulk - 65,000 cost £1k which is 1.5p each.
True, for mapping outcode isn't accurate, but for 'nearest' queries it's OK. And yes, with a service you don't have to piss about yourself with the updated. 1.5p is more like it. In that case and based on the arguments you gave, it's a good deal indeed. I got a sample of the Royal Mail themselves, the PAF data. That's both a rip-off AND a nightmare. Don't do there, let others do that for you.
You might also want to try iShareMaps. They have a decent postcode geocoder. see www.geocode.isharemaps.com
..did you decide on? I'm just about to embark on my own (and first) project and also need to use geomapping but can't find full postcode / lat long tables, unless paying. Hence your advice would be much appreciated.. Thanks
Showing satellitepictures at streetlevel of a UK postcode, try "Picsfromspace, lookup your place by address" at "http://www.walweb.nl/picsfromspace"
Resurrecting this because I found the definitive answer and this threads ranks first page Google for relevant terms. Emad Fanous is a fantastic person who bought a dedicated server and coded some great tools to do world wide geocoding for a variety of input data and allows a broad range of output options as well. He allows mass geocoding, yesterday I emailed him about doing 9000 UK postcodes to WSG-84 Lat/Lon coordinates and he said it was fine. He even added a plain text output option. In PHP all you have to do is this for each Postcode: $url = "http://geo.localsearchmaps.com/?zip="; $url .= urlencode($post_code); $url .= "&country=UK&use=google2&format=txt"; if ($grab_coordinates = file_get_contents($url)) { $coord_pair = explode(", ", $grab_coordinates); if (sizeof($coord_pair) == 2) { // OK we've got what we need so chuck it in the DB! $latitude = $coord_pair[0]; $longitude = $coord_pair[1]; $sql = "etc"; } } PHP: Read the linked blog post for other input options. Truly wicked and hopefully the Royal Mail will get done in for monopolizing their postcode data soon.
I have written a tutorial on the free geocoding of UK postcodes, along with a PHP class, that you can read at http://www.mattpryor.co.uk/tutorials/show/1/
I dont think your allowed to use google maps to mass geocode a database, its against the T&C, it used to be against the T&C to store the lat/lon in the database but i know they have made many changes and i believe that restriction was removed. I would like confirmation from google on that before using it but looks really interesting. Ona more positive note there has been some really amazing projects to make a public domain postcode list, PLEASE PLEASE contribute to this as it will be the end of all our problems! Its actually really useable allready, you jsut need to click the map and type your postcode. Add all postcodes you can think of and can locate on the map! http://www.npemap.org.uk/