[postgis-users] Data cleaning options

Paul Ramsey pramsey at refractions.net
Fri May 11 09:05:24 PDT 2007


Your first attempt might be to run

select object_id from thetable where not isvalid(the_geom) and not 
isvalid(buffer(the_geom),0.0));

That will give you all your "hard nuts". If you're really lucky, it 
gives you nothing at all. In which case you can just update your data 
and go on your way.

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

Tim Keitt wrote:
> Hi All,
> 
> I have a large collection of rather malformed polygons in postgis and
> need to clean them somehow. Running isvalid() on the geometry column
> gives many "Ring self-intersection" errors, some "Interior is
> disconnected" errors and the always enjoyable "Too few points in
> geometry component" error. What options are there for
> cleaning/correcting polygons?
> 
> THK
> 


-- 

   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