Skip to content

Instantly share code, notes, and snippets.

@ktopping
Created June 24, 2010 09:56
Show Gist options
  • Save ktopping/451258 to your computer and use it in GitHub Desktop.
Save ktopping/451258 to your computer and use it in GitHub Desktop.
use strict;
use mySociety::GeoUtil qw/national_grid_to_wgs84/;
use CAM::DBF;
my $filename = $ARGV[0];
my $dbf = CAM::DBF->new($filename);
# Double-check the data is as we expect.
my @fieldnames = $dbf->fieldnames();
die if $fieldnames[0] ne "PC1" || $fieldnames[6] ne "X" || $fieldnames[7] ne "Y";
for my $row (0 .. $dbf->nrecords()-1) {
my @r = $dbf->fetchrow_array($row);
my ($pc, $east, $north) = ($r[0], $r[6], $r[7]);
my ($lat, $lng) = national_grid_to_wgs84($east, $north, "I"); # "I" means Ireland
print "$pc,$lat,$lng\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment