More Geocoding

1 July 2009 23:18

More geocoding fun today, this time done with perl. For what I want to do, convert OS Grid easting and northing into latitude and longitude using an API, like Yahoo! was going to take ages due to throttling. Turns out that in perl using the handy Geography-NationalGrid-1.6 CPAN package it’s a lot easier and gives for most cases a result very close together.

Here’s a quick example:

#!/usr/bin/perl
use Geography::NationalGrid;
my $point1 = new Geography::NationalGrid( 'GB',
Easting => '385600',
Northing => '801900'
);
print "Latitude " . $point1->latitude . " Longitude " . $point1->longitude . "\n";

You can also give it a grid reference like TH 1234 1234 or a latitude and longitude.

Filed: Technology // Tagged: ,

You can follow any responses to this entry through the RSS 2.0 feed.

You can leave a comment or leave a trackback from your own site.

Leave a Reply

 
What's ianteresting?   •   Twitter   •   About   •   Contact
©2012 Ian Winter. All Rights Reserved.   •   Powered by WordPress   •   Hosted at Memset