[postgis-users] Newbie Geocoding Error

Paragon Corporation lr at pcorp.us
Sat Jul 9 11:23:09 PDT 2011


Mike,
 
Which version are you running with?  For the newer ones -- if you look at
the normalize_address function , you should see a stamp in the beginning of
the code that has
 
--$Id: normalize_address.sql 7616 2011-07-07 12:41:13Z robe $-
 
That is the latest version stamp. Really old versions don't even have a
stamp.   If you are running something older than a week or 2 ago, that is
probably why you are having these issues.
The easiest way to upgrade to the latest is:
1) Download the PostGIS 2.0  tar ball from here --
http://www.postgis.org/download/  (the tiger_geocoder is in
extras/tiger_geocoder/tiger_2010)  
-- (This new version requires PostGIS 1.5+ and PostgreSQL 8.4+)
 
2) Edit the  upgrade_geocoder.sh file with your postgres settings and then
run it.
 
3) Run the Missing_indexes_Generate_Script() to get the commands to build
indexes you may be missing.
 
http://www.postgis.org/documentation/manual-svn/Missing_Indexes_Generate_Scr
ipt.html
 and then execute that generated script
 
----------------------------------------------------------------------------
--------------
I think this is a bug I might have fixed.  When I run normalize on this I
don't get an error, and yours seems to be breaking in the normalize step.
 
When I run
SELECT * FROM normalize_address('3261 South West 160 Avenue, Miramar, FL
33027')
 
I get the below
 
 
 
 address | predirabbrev | streetname | streettypeabbrev | postdirabbrev |
internal | location | stateabbrev |  zip  | parsed
---------+--------------+------+------------------+---------------+---------
-+----------+-------------+-------+--------
    3261 | SW              | 160            | Ave              |
| Miramar  | FL          | 33027 | t
 
 
Unfortunately I don't have Florida data loaded so can't tell if it will
geocode right or not. 
 
Regarding bad rating results, the issue is often what the address gets
normalized to and  a bad normalization is often the cause of bad geocoding
results.  So probably the
best check to do is do a simple
 
SELECT  * FROM normalize_address(...);
 
and see what it comes with and if that normalized addess makes sense.
 
There are many cases where it doesn't that I have fixed recently and some
more that are known bugs I am working on.  Check out the list of issues and
closed ones for details:
http://trac.osgeo.org/postgis/query?component=tiger+geocoder
 
 
The other issue I see with your code -- which perhaps it was for testing, is
that you are normalizing twice.
 
You should just be doing a:
geocode('3261 South West 160 Avenue, Miramar, FL 33027')
 
No need for those extra steps.
 
You might want to take a look at the manual for recent improvements made too
and examples:
http://www.postgis.org/documentation/manual-svn/Geocode.html
 
Hope that helps,
Regina
http://www.postgis.us


  _____  

From: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of Michael
Papet
Sent: Saturday, July 09, 2011 12:56 PM
To: postgis-users at postgis.refractions.net
Subject: [postgis-users] Newbie Geocoding Error


Hi,

I'm a newbie using postgis from Debian's Testing repos. (v. 1.5)  I used the
tiger_loader script to load the data.

Plenty of addresses geocode just fine.   Using the below query, I get an
error.

SELECT g.rating,  ST_X(ST_AsEWKT(ST_SnapToGrid(g.geomout,0.00000001))) As
lon, ST_Y(ST_AsEWKT(ST_SnapToGrid(g.geomout,0.00000001))) As lat,
ST_AsEWKT(ST_SnapToGrid(g.geomout,0.00000001)) As wktlonlat, 
    (addy).address As stno, (addy).streetname As street, 
    (addy).streettypeabbrev As styp, (addy).location As city,
(addy).stateabbrev As st,(addy).zip 
    FROM geocode(pprint_addy(normalize_address('3261 South West 160 Avenue,
Miramar, FL 33027'))) As g 
    order by g.rating

Error: ERROR: query "SELECT substring(reducedStreet, '(?i)(^' || name
        || ')' || ws) FROM direction_lookup WHERE
         reducedStreet ILIKE '%' || name || '%'  AND
texticregexeq(reducedStreet, '(?i)(^' || name || ')' || ws)
        ORDER BY length(name) DESC" returned more than one row
  Where: PL/pgSQL function "normalize_address" line 280 at assignment
PL/pgSQL function "geocode" line 10 at assignment
SQLState:  21000
ErrorCode: 0

The problem is with the street name 'South West 160 Avenue.' Is that a bug?

Also, Southwest 160 Avenue' returns some very low-accuracy results.  What
queries can I use to view the tiger data to increase the rating? In my head,
I'd like to select all street names in the zip code 33027 using like
statements to narrow results to figure out why the g.rating is so bad on
this address.  But, that's probably different than how TIGER data is
structured.  Can someone post an example of a select to improve the
accuracy?  It's also possible the address is slightly wrong, but I get
accurate results from google earth.

Thanks in advance.





-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20110709/57780808/attachment.html>


More information about the postgis-users mailing list