[postgis-users] Invalid Geometries from shapefiles

Bruce Rindahl rindahl at lrcwe.com
Wed Feb 7 10:17:42 PST 2007


Paul
I have tracked it down to 40 "Ring Self-intersection".  Like you said there
is no magic bullet.

As for CleanGeometry, I used the most expensive GIS software package in the
world developed by a company with all the money in the world to check the
geometry of this shapefile and it found  ........  nothing.  I am not sure I
can help your funding but as you said it sure would be nice and I know you
would have a better product.

Bruce


-----Original Message-----
From: Paul Ramsey [mailto:pramsey at refractions.net] 
Sent: Wednesday, February 07, 2007 10:53 AM
To: rindahl at lrcwe.com; PostGIS Users Discussion
Subject: Re: [postgis-users] Invalid Geometries from shapefiles

If someone wants to fun CleanGeometry(), I am all ears :)  There is no 
magic bullet to make invalid geometries valid, but invalidities tend to 
fall in a few major categories, so a CleanGeometry() could be fairly 
effective.

In the meantime, do this, perhaps:

update yourtable set the_geom = buffer(the_geom,0.0) where not 
isvalid(the_geom);

If that doesn't work, try running a snaptogrid() inside the buffer with 
a very small tolerance.  Both buffer and snaptogrid tend to squash out 
invalidities, in many (but not all) cases.

Paul

Bruce Rindahl wrote:
> I have an application that stores floodplains in a PostGIS database for
> later display in a web mapping application.  The floodplains are derived
> from shapefiles and are converted using shp2pgsql.  The issue is some of
the
> shapes are invalid when converted to the geometry format in PostGIS.  When
> these invalid geometries are manipulated by certain operators, the results
> are not as expected (for example intersection returns a geometry
collection
> instead of a multipolygon).
> Are there some guidelines or things to look for in shapefiles to assure
the
> geometry is valid?  Most of the problems occur when a polygon has an
> interior island.  All of the tools we are using accepts these shapefiles
as
> valid but will cause problems when converted.
> Thanks


-- 

   Paul Ramsey
   Refractions Research
   http://www.refractions.net
   pramsey at refractions.net
   Phone: 250-383-3022
   Cell: 250-885-0632






More information about the postgis-users mailing list