Pagc_Normalize_Address — Given a textual street address, returns a composite norm_addy
type that has road suffix, prefix and type standardized, street, streetname etc. broken into separate fields. This function will work with just the lookup data packaged with the tiger_geocoder (no need for tiger census data). Requires address_standardizer extension.
norm_addy pagc_normalize_address(
varchar in_address)
;
Given a textual street address, returns a composite norm_addy
type that has road suffix, prefix and type standardized, street, streetname etc. broken into separate fields. This is the first step in the geocoding process to get all addresses into normalized postal form. No other data is required aside from what is packaged with the geocoder.
This function just uses the various pagc_* lookup tables preloaded with the tiger_geocoder and located in the tiger
schema, so it doesn't need you to download tiger census data or any other additional data to make use of it. You may find the need to add more abbreviations or alternative namings to the various lookup tables in the tiger
schema.
It uses various control lookup tables located in tiger
schema to normalize the input address.
Fields in the norm_addy
type object returned by this function in this order where () indicates a field required by the geocoder, [] indicates an optional field:
There are slight variations in casing and formatting over the Normalize_Address.
初出: 2.1.0
This method needs address_standardizer extension.
(address) [predirAbbrev] (streetName) [streetTypeAbbrev] [postdirAbbrev] [internal] [location] [stateAbbrev] [zip]
The native standardaddr of address_standardizer extension is at this time a bit richer than norm_addy since its designed to support international addresses (including country). standardaddr equivalent fields are:
house_num,predir, name, suftype, sufdir, unit, city, state, postcode
address
is an integer: The street number
predirAbbrev
is varchar: Directional prefix of road such as N, S, E, W etc. These are controlled using the direction_lookup
table.
streetName
varchar
streetTypeAbbrev
varchar abbreviated version of street type: e.g. St, Ave, Cir. These are controlled using the street_type_lookup
table.
postdirAbbrev
varchar abbreviated directional suffice of road N, S, E, W etc. These are controlled using the direction_lookup
table.
internal
varchar internal address such as an apartment or suite number.
location
varchar usually a city or governing province.
stateAbbrev
varchar two character US State. e.g MA, NY, MI. These are controlled by the state_lookup
table.
zip
varchar 5-digit zipcode. e.g. 02109.
parsed
boolean - denotes if addess was formed from normalize process. The normalize_address function sets this to true before returning the address.
Single call example
SELECT addy.* FROM pagc_normalize_address('9000 E ROO ST STE 999, Springfield, CO') AS addy; address | predirabbrev | streetname | streettypeabbrev | postdirabbrev | internal | location | stateabbrev | zip | parsed ---------+--------------+------------+------------------+---------------+-----------+-------------+-------------+-----+-------- 9000 | E | ROO | ST | | SUITE 999 | SPRINGFIELD | CO | | t
Batch call. There are currently speed issues with the way postgis_tiger_geocoder wraps the address_standardizer. These will hopefully be resolved in later editions. To work around them, if you need speed for batch geocoding to call generate a normaddy in batch mode, you are encouraged to directly call the address_standardizer standardize_address function as shown below which is similar exercise to what we did in Normalize_Address that uses data created in Geocode.
WITH g AS (SELECT address, ROW((sa).house_num, (sa).predir, (sa).name , (sa).suftype, (sa).sufdir, (sa).unit , (sa).city, (sa).state, (sa).postcode, true)::norm_addy As na FROM (SELECT address, standardize_address('tiger.pagc_lex' , 'tiger.pagc_gaz' , 'tiger.pagc_rules', address) As sa FROM addresses_to_geocode) As g) SELECT address As orig, (g.na).streetname, (g.na).streettypeabbrev FROM g; orig | streetname | streettypeabbrev -----------------------------------------------------+---------------+------------------ 529 Main Street, Boston MA, 02129 | MAIN | ST 77 Massachusetts Avenue, Cambridge, MA 02139 | MASSACHUSETTS | AVE 25 Wizard of Oz, Walaford, KS 99912323 | WIZARD OF | 26 Capen Street, Medford, MA | CAPEN | ST 124 Mount Auburn St, Cambridge, Massachusetts 02138 | MOUNT AUBURN | ST 950 Main Street, Worcester, MA 01610 | MAIN | ST