Geo::Coder::Free::OpenAddresses - Provides a geocoding functionality to the data from


Version 0.28


    use Geo::Coder::Free::OpenAddresses;

    # Use a local download of
    my $geocoder = Geo::Coder::Free::OpenAddresses->new(openaddr => $ENV{'OPENADDR_HOME'});
    $location = $geocoder->geocode(location => '1600 Pennsylvania Avenue NW, Washington DC, USA');

    my @matches = $geocoder->geocode({ scantext => 'arbitrary text', region => 'GB' });


Geo::Coder::Free::OpenAddresses provides an interface to the free geolocation database at

Refer to the source URL for licencing information for these files:

To install:

1. download the data from You will find licencing information on that page. 2. unzip the data into a directory. To be clear, if you run "ls -l $OPENADDR_HOME" you should see a list of two-lettered countries e.g 'us'. 3. point the environment variable OPENADDR_HOME to that directory and save in the profile of your choice. 4. run the createdatabases.PL script which imports the data into an SQLite database. This process will take some time.



    $geocoder = Geo::Coder::Free::OpenAddresses->new(openaddr => $ENV{'OPENADDR_HOME'});

Takes an optional parameter openaddr, which is the base directory of the OpenAddresses data downloaded from

Takes an optional parameter cache, which points to an object that understands get() and set() messages to store data in


    $location = $geocoder->geocode(location => $location);

    print 'Latitude: ', $location->lat(), "\n";
    print 'Longitude: ', $location->long(), "\n";

    # TODO:
    # @locations = $geocoder->geocode('Portland, USA');
    # diag 'There are Portlands in ', join (', ', map { $_->{'state'} } @locations);

When looking for a house number in a street, if that address isn't found but that street is found, a place in the street is given. So "106 Wells Street, Fort Wayne, Allen, Indiana, USA" isn't found, a match for "Wells Street, Fort Wayne, Allen, Indiana, USA" will be given instead. Arguably that's incorrect, but it is the behaviour I want.


    $location = $geocoder->reverse_geocode(latlng => '37.778907,-122.39732');

To be done.


Does nothing, here for compatibility with other geocoders


Nigel Horne <>

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The contents of lib/Geo/Coder/Free/OpenAddresses/databases comes from


Lots of lookups fail at the moment.

The code has yet to be completed. There are die()s where the code path has yet to be written.

The openaddresses data doesn't cover the globe.

Can't parse and handle "London, England".

Currently only searches US and Canadian data.

If you do search in the UK, only look up towns, full addresses aren't included. So these will print the same.

    use Geo::Coder::Free::OpenAddresses;

    $location = $geo_coder->geocode(location => '22 Central Road, Ramsgate, Kent, England');
    print $location->{latitude}, "\n";
    print $location->{longitude}, "\n";
    $location = $geo_coder->geocode(location => '7 Hillbrow Road, St Lawrence, Thanet, Kent, England');
    print $location->{latitude}, "\n";
    print $location->{longitude}, "\n";


VWF, openaddresses.


Copyright 2017-2020 Nigel Horne.

The program code is released under the following licence: GPL for personal use on a single computer. All other users (including Commercial, Charity, Educational, Government) must apply in writing for a licence for use from Nigel Horne at `<njh at>`.