[postgis-users] newbie question about non closed rings

Kevin Neufeld kneufeld at refractions.net
Wed Apr 15 08:39:29 PDT 2009


You could try snapping your geometries to a grid after they are in the database.

http://postgis.refractions.net/documentation/manual-svn/ST_SnapToGrid.html


postgis=# SELECT 
ST_IsValid('0106000000010000000103000000010000000700000024213D12AA7BFD40945FF42576511941676A32F9017BFD40B1D67BEA7E511941C3E3C640DB7DFD4026CE38F4EE531941C91289C5AA7EFD40017B8518E3531941646F1599AB7DFD409627F1F0AE521941355EBA49547CFD407B14AEC74652194123213D12AA7BFD40945FF42576511941');
NOTICE:  IllegalArgumentException: points must form a closed linestring
  st_isvalid
------------
  f
(1 row)


postgis=# SELECT 
ST_IsValid(ST_SnapToGrid('0106000000010000000103000000010000000700000024213D12AA7BFD40945FF42576511941676A32F9017BFD40B1D67BEA7E511941C3E3C640DB7DFD4026CE38F4EE531941C91289C5AA7EFD40017B8518E3531941646F1599AB7DFD409627F1F0AE521941355EBA49547CFD407B14AEC74652194123213D12AA7BFD40945FF42576511941', 
0.00001));
  st_isvalid
------------
  t
(1 row)


-- Kevin

G. van Es wrote:
> The shapefile is created with software from Bentley.
> PostgreSQL is version 8.3.4 on Ubuntu
> PostGis is version 1.3
> 
> I also see a difference between conversion as WKB and WKT (-w option). If I use shp2pgsql with the -w option there are far less records that fail.
> 
> So can this be an issue with rounding up numbers? In WKT I see a tiny difference between some start and end points on failing records.
> 
> And if so, is there a possibility to ignore those tiny differences?
> 
> Thanks again,
> Ge
> 
> 



More information about the postgis-users mailing list