[postgis-users] index-based inconsistencies

Robert Hollingsworth reh2 at prodigy.net
Wed Mar 11 13:54:44 PDT 2009

using postgresql 8.3.4
using postgis 1.3.3
using geos 3.0.0
using proj 4.6.1

I'm encountering a couple of oddities which I'm pretty sure are related.

I have US Census Congressional districts modeled in PostGIS.

I've got a simple php program that uses ST_Within( ) to check a lat,lon against the congressional district polygons.  A small number of the districts are causing the query to return zero records incorrectly.

I've also got a simple php-mapscript with a LAYER to simply display all of these congressional districts.  When zoomed out around 1:400k and further out, these peculiar districts appear along side their neighbors.  When I zoom in closer, these same districts stop appearing.

I'm pretty sure this is a problem with the spatial indexes, which were created by shp2pgsql, because I converted the search program from ST_Within( ) to _ST_Within( ), which is advertised as skipping the indexing.  _ST_Within( ) is a bit slower, but finds these districts ok.

I've run VACUUM ANALYZE on the table, but this hasn't changed anything.

I haven't dug into the mapserver pg driver to see if there is any way for me to manipulate the generated query into skipping indexes.

I haven't yet dug into the records further to see if they have pathological bboxes or similar.

There are no holes in these polygons.

Anyone have any ideas on this?

Robert H.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20090311/2e726486/attachment.html>

More information about the postgis-users mailing list