Geocoding
I didn’t take notes on installing Geo::Coder::US, but it was straightward. I fired up CPAN, and typed install Geo::Coder::US and away it went. Then when it was done I fetched the TigerLINE files for Louisiana and the FIPS 55 data, the “all” zip archive, rather than Louisiana specific. You’ll note that the TigerLINE page is perfect for a wget -r, which is what I used.
I imported the data using the scripts mentioned in the documentation.
[alan@tno ~] /tno/bin/perl /tno/geo/eg/import_fips.pl
/tno/var/geo/gecode.db
AllFIPS55_20050215.txt
[alan@tno ~] /tno/bin/perl /tno/geo/eg/import_tiger_zip.pl
/tno/var/geo/geocode.db
tiger/*.zip
You’ll notice that I’ve build a Perl for the project, rather than using the system Perl. I used to do a lot of work with Apache and mod_perl, where I developed this practice.
Then I can write a simple Perl script to geocode an address.
#!/tno/bin/perl
use Geo::Coder::US;
use Data::Dumper;
Geo::Coder::US->set_db( "/tno/var/geo/geocode.db" );
# Terranova Bother's Supermarket...
my @matches = Geo::Coder::US->geocode(
"3308 Esplanade, New Orleans, LA");
for (@matches) {
print "Location: $$_{lat} $$_{long}n";
}
my @matches = Geo::Coder::US->geocode(
"Esplanade & Grand Route St John, New Orleans, LA");
for (@matches) {
print "Location: $$_{lat} $$_{long}n";
}
Good to go. The next step is to create a CGI script that can generate an XML reponse that I can get to from JavaScript and XSLT 2.0.
October 23rd, 2005 at 5:48 pm
[…] Geocoding is installed. Now to create a REST interface I can use from XML. […]