[postgis-users] Error "pt_in_ring_2d: V[n] != V[0]"

Daniel Griscom griscom at suitable.com
Sun Jun 24 07:04:57 PDT 2007


I have a set of regions (countries and states) that was built in 
ArcView, simplified using the MapShaper website at 
<http://www.mapshaper.org/test/demo.html>, processed using shp2pgsql, 
and then imported into PostgreSQL.

Queries on the regions work IF the query is for latitudes south of 
40N. For 40N and northward, I get an internal PostGIS error:

pg_query(): Query failed: ERROR: pt_in_ring_2d: V[n] != V[0] 
(2.79994e+006 2.08225e+007 != 2.79994e+006 2.08225e+007)

The values in parenthesis change from location to location, but 
strangely the first displayed pair always DOES equal the second pair. 
Googling came up with the following statement: "That message comes 
from an integrity checker that verifies first point to be equal to 
last point in a linear ring", which seems to match the error message. 
I believe (though I'm not sure; I don't have ArcView myself) that the 
simplified shapefile was successfully loaded and displayed in 
ArcView, so by that test the shapefile is valid. I don't know what 
MapShaper simplification algorithm was used; I'm guessing the default 
(Douglas-Peucker).


I checked the PostGIS source (lwgeom/measures.c, line 40) and the 
first and last points are compared using a memory compare. Guess: 
MapShaper simplies the shapefile in such a way that the first and 
last points are trivially different, which violates PostGIS' 
assumptions, while not violating ArcView's.


Does this sound right? Any thoughts on how to fix this, either in 
PostGIS or in my workflow?


Thanks,
Dan

-- 
Daniel T. Griscom             griscom at suitable.com
Suitable Systems              http://www.suitable.com/
1 Centre Street, Suite 204    (781) 665-0053
Wakefield, MA  01880-2400



More information about the postgis-users mailing list