codeforkansascity / address-api

A address database accessible through an API that will return attributes about the address, neighborhood, council district, zoning...
http://address-api.codeforkc.org
MIT License
5 stars 9 forks source link

Improve parsing of addresses for standardization #112

Open zmon opened 7 years ago

zmon commented 7 years ago

Background

In the very first version we used the Census Tiger database, but was impossible to install with our understanding. The following articles show how to install part of the Tiger tools for address standardization and parsing.

To Install in code4kc geo database:

CREATE EXTENSION address_standardizer;
CREATE EXTENSION postgis_tiger_geocoder;

To test:

SELECT (g.na).address,
       (g.na).predirAbbrev,
       (g.na).streetName,
       (g.na).streetTypeAbbrev,
       (g.na).postdirAbbrev,
       (g.na).internal,
       (g.na).location,
       (g.na).stateAbbrev,
       (g.na).zip,
       (g.na).parsed
 FROM (SELECT normalize_address('210 w 19th terr, kansas city mo 64106') As na) As g;

Which should result in:

 address | predirabbrev | streetname | streettypeabbrev | postdirabbrev | internal |  location   | stateabbrev |  zip  | parsed 
---------+--------------+------------+------------------+---------------+----------+-------------+-------------+-------+--------
     210 | W            | 19th       | Ter              |               |          | kansas city | MO          | 64106 | t

To test pagc_normalize_address

SELECT addy.* FROM pagc_normalize_address('9000 E ROO ST STE 999, Springfield, CO') AS addy;

Should return

 address | predirabbrev | streetname | streettypeabbrev | postdirabbrev | internal  |  location   | stateabbrev | zip | parsed 
---------+--------------+------------+------------------+---------------+-----------+-------------+-------------+-----+--------
    9000 | E            | ROO        | ST               |               | SUITE 999 | SPRINGFIELD | CO          |     | t