Ge, For this kind of thing I usually output to wkt and then use sed to convert the POLYGON/MULTIPOLYGON to MULTILINESTRING format. Then I bring the data in as MULTILINESTRING/LINESTRING and use BuildArea to reform the POLYGONS using the ST_SnapToGrid approach Kevin outlined.
I'm sure there is probably an easier way, but haven't thought of it. Since PostGIS won't allow these geometries in at all. Mark Cave-Ayland, I forget were we planning on making this a switch option in later versions of PostGIS? So that you could bring in polygons with unclosed rings and fix them in the db? Hope that helps, Regina -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of G. van Es Sent: Wednesday, April 15, 2009 1:44 PM To: PostGIS Users Discussion Subject: Re: [postgis-users] newbie question about non closed rings Thanks for pointing me in this direction. Trying the following however doesn't give me the desired result. select st_isvalid(ST_SnapToGrid('01060000000100000001030000000100000017000000F16E09 F3BEB70041931C90EF94731941E8FBA9F157B70041713D0AD78C73194130DD24062BB600416B BC7413787319419CC420B0F1B50041DE24060174731941C3F5285CF1B5004179E92631757319 41B5C876BEF0B50041DBF97E6A7773194100000000EAB50041D7A370BD8F731941C520B072E9 B5004185EB51B8917319416991ED7CE5B5004100000000A07319418C6CE7FBDCB50041BF9F1A AFBE731941D578E926AEB50041B39DEFA76574194121B07268E6B50041D578E9A66974194159 39B4C810B70041B5C8763E7E7419419418045679B700415C8FC27586741941AA9A096982B700 411CBA7F12677419418FF6FD8BA3B700419D553774F4731941815E0E35AEB7004174547794CF 7319418B08F52DB1B700417652884CC5731941C49D7A24B7B70041FFECFAAAB07319415D8FC2 F5BBB7004100000000A0731941115839B4BDB70041D122DBF99973194119970B76BEB7004172 266DE996731941C5B908F3BEB70041CEF992EF94731941',0.0001)); ERROR: geometry contains non-closed rings --- On Wed, 4/15/09, Kevin Neufeld <[email protected]> wrote: > From: Kevin Neufeld <[email protected]> > Subject: Re: [postgis-users] newbie question about non closed rings > To: "PostGIS Users Discussion" <[email protected]> > Date: Wednesday, April 15, 2009, 8:39 AM 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('0106000000010000000103000000010000000700000024213D12AA7BFD > 40945FF42576511941676A32F9017BFD40B1D67BEA7E511941C3E3C640DB7DFD4026CE > 38F4EE531941C91289C5AA7EFD40017B8518E3531941646F1599AB7DFD409627F1F0AE > 521941355EBA49547CFD407B14AEC74652194123213D12AA7BFD40945FF42576511941 > '); > NOTICE: IllegalArgumentException: points must form a closed > linestring st_isvalid > ------------ > f > (1 row) > > > postgis=# SELECT > ST_IsValid(ST_SnapToGrid('01060000000100000001030000000100000007000000 > 24213D12AA7BFD40945FF42576511941676A32F9017BFD40B1D67BEA7E511941C3E3C6 > 40DB7DFD4026CE38F4EE531941C91289C5AA7EFD40017B8518E3531941646F1599AB7D > FD409627F1F0AE521941355EBA49547CFD407B14AEC74652194123213D12AA7BFD4094 > 5FF42576511941', > 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 > > > > > _______________________________________________ > postgis-users mailing list > [email protected] > http://postgis.refractions.net/mailman/listinfo/postgis-users > _______________________________________________ postgis-users mailing list [email protected] http://postgis.refractions.net/mailman/listinfo/postgis-users __________ Information from ESET NOD32 Antivirus, version of virus signature database 4011 (20090415) __________ The message was checked by ESET NOD32 Antivirus. http://www.eset.com _______________________________________________ postgis-users mailing list [email protected] http://postgis.refractions.net/mailman/listinfo/postgis-users
