Re: [postgis-users] ERROR: geometry contains non-closed rings
If you are exporting from ArcMap (and have a copy of the software) then run the Repair Geometry tool before export. This seems to fix most issues with non closed rings that surface in PostGIS and other tools. Phil > >From: Ben Madin >To: PostGIS Users Discussion >Sent: Thursday, 18 August 2011, 17:34 >Subject: Re: [postgis-users] ERROR: geometry contains non-closed rings > >G'day Puneet, > >Maybe you could start with : > >SELECT gid, st_isvalidreason(the_geom), st_summary(the_geom) FROM data WHERE >st_isclosed(the_geom) is FALSE; > >cheers > >Ben > >On 19/08/2011, at 12:19 AM, Mr. Puneet Kishor wrote: > >> >> I loaded a bunch of data (that came from ArcMap) into PostGIS (1.5.3) via >> shp2pgsql and am trying to draw it with MapServer 6.0.1. I get >> >>> msDrawMap(): Image handling error. Failed to draw layer named 'foo'. >>> msPostGISLayerWhichShapes(): Query error. Error (ERROR: geometry contains >>> non-closed rings ) >> >> >> Many thanks in advance for your suggestions. >> >> -- >> Puneet Kishor >> >> ___ >> postgis-users mailing list >> postgis-users@postgis.refractions.net >> http://postgis.refractions.net/mailman/listinfo/postgis-users > >___ >postgis-users mailing list >postgis-users@postgis.refractions.net >http://postgis.refractions.net/mailman/listinfo/postgis-users > > >___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users
Re: [postgis-users] ERROR: geometry contains non-closed rings
A newer PostGIS should give you a valid return from ST_IsValidReason rather than an exception for those non-closed linear rings. And the ST_MakeValid function should close them for you. I'm afraid "newer" means 2.0.0SVN here, which also means dump-reload (I hope you do can dump, can you ?) For a "simpler" solution you'll need to write a function to ensure rings are closed. --strk; On Fri, Aug 19, 2011 at 03:36:27PM +0530, Mr. Puneet Kishor wrote: > > On Aug 19, 2011, at 10:26 AM, Mr. Puneet Kishor wrote: > > > Ben, > > > > On Aug 18, 2011, at 10:04 PM, Ben Madin wrote: > > > >> SELECT gid, st_isvalidreason(the_geom), st_summary(the_geom) FROM data > >> WHERE st_isclosed(the_geom) is FALSE; > > > > > > I am not entirely sure what the above was supposed to accomplish (I am > > assuming it would have given me the reason for features being invalid), > > however, I ran the query and I got 0 (zero) rows. > > > > h a bit more on the above > > SELECT Count(*) FROM data WHERE ST_IsClosed(the_geom) IS FALSE; > 0 rows > > SELECT Count(*) FROM data WHERE ST_IsValid(the_geom) IS FALSE; > NOTICE: IllegalArgumentException: Points of LinearRing do not form a closed > linestring > NOTICE: IllegalArgumentException: Points of LinearRing do not form a closed > linestring > NOTICE: Ring Self-intersection at or near point -125.35 63.3748 > NOTICE: Ring Self-intersection at or near point -105.317 25.7493 > NOTICE: Ring Self-intersection at or near point -79.7995 15.6005 > NOTICE: Ring Self-intersection at or near point -108.085 29.1395 > NOTICE: Ring Self-intersection at or near point -110.182 25.8712 > NOTICE: Self-intersection at or near point -119.188 77.3311 > NOTICE: Ring Self-intersection at or near point -120.647 48.8028 > NOTICE: Ring Self-intersection at or near point -124.845 61.0461 > NOTICE: Ring Self-intersection at or near point -100.63 62.7163 > NOTICE: Self-intersection at or near point -69.7338 64.1648 > NOTICE: Self-intersection at or near point -69.2501 58.2279 > NOTICE: Self-intersection at or near point -65.9125 52.0649 > NOTICE: Ring Self-intersection at or near point -74.8998 50.7265 > NOTICE: Self-intersection at or near point -82.6883 72.1031 > NOTICE: Ring Self-intersection at or near point -27.1663 71.0088 > NOTICE: Ring Self-intersection at or near point -99.0254 23.1045 > NOTICE: Ring Self-intersection at or near point -93.6802 37.1155 > NOTICE: Ring Self-intersection at or near point -73.2305 9.59044 > NOTICE: Ring Self-intersection at or near point -63.4384 13.1596 > 21 rows > > SELECT gid, ST_IsValidReason(the_geom) FROM data WHERE ST_isvalid(the_geom) > IS FALSE; > NOTICE: IllegalArgumentException: Points of LinearRing do not form a closed > linestring > NOTICE: IllegalArgumentException: Points of LinearRing do not form a closed > linestring > > > ERROR: POSTGIS2GEOS conversion failed > > ** Error ** > > ERROR: POSTGIS2GEOS conversion failed > SQL state: XX000 > > ___ > postgis-users mailing list > postgis-users@postgis.refractions.net > http://postgis.refractions.net/mailman/listinfo/postgis-users -- () Free GIS & Flash consultant/developer /\ http://strk.keybit.net/services.html ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users
Re: [postgis-users] ERROR: geometry contains non-closed rings
On Aug 19, 2011, at 10:26 AM, Mr. Puneet Kishor wrote: > Ben, > > On Aug 18, 2011, at 10:04 PM, Ben Madin wrote: > >> SELECT gid, st_isvalidreason(the_geom), st_summary(the_geom) FROM data WHERE >> st_isclosed(the_geom) is FALSE; > > > I am not entirely sure what the above was supposed to accomplish (I am > assuming it would have given me the reason for features being invalid), > however, I ran the query and I got 0 (zero) rows. > h a bit more on the above SELECT Count(*) FROM data WHERE ST_IsClosed(the_geom) IS FALSE; 0 rows SELECT Count(*) FROM data WHERE ST_IsValid(the_geom) IS FALSE; NOTICE: IllegalArgumentException: Points of LinearRing do not form a closed linestring NOTICE: IllegalArgumentException: Points of LinearRing do not form a closed linestring NOTICE: Ring Self-intersection at or near point -125.35 63.3748 NOTICE: Ring Self-intersection at or near point -105.317 25.7493 NOTICE: Ring Self-intersection at or near point -79.7995 15.6005 NOTICE: Ring Self-intersection at or near point -108.085 29.1395 NOTICE: Ring Self-intersection at or near point -110.182 25.8712 NOTICE: Self-intersection at or near point -119.188 77.3311 NOTICE: Ring Self-intersection at or near point -120.647 48.8028 NOTICE: Ring Self-intersection at or near point -124.845 61.0461 NOTICE: Ring Self-intersection at or near point -100.63 62.7163 NOTICE: Self-intersection at or near point -69.7338 64.1648 NOTICE: Self-intersection at or near point -69.2501 58.2279 NOTICE: Self-intersection at or near point -65.9125 52.0649 NOTICE: Ring Self-intersection at or near point -74.8998 50.7265 NOTICE: Self-intersection at or near point -82.6883 72.1031 NOTICE: Ring Self-intersection at or near point -27.1663 71.0088 NOTICE: Ring Self-intersection at or near point -99.0254 23.1045 NOTICE: Ring Self-intersection at or near point -93.6802 37.1155 NOTICE: Ring Self-intersection at or near point -73.2305 9.59044 NOTICE: Ring Self-intersection at or near point -63.4384 13.1596 21 rows SELECT gid, ST_IsValidReason(the_geom) FROM data WHERE ST_isvalid(the_geom) IS FALSE; NOTICE: IllegalArgumentException: Points of LinearRing do not form a closed linestring NOTICE: IllegalArgumentException: Points of LinearRing do not form a closed linestring ERROR: POSTGIS2GEOS conversion failed ** Error ** ERROR: POSTGIS2GEOS conversion failed SQL state: XX000 ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users
Re: [postgis-users] ERROR: geometry contains non-closed rings
On Aug 18, 2011, at 10:04 PM, Paul Ramsey wrote: > I think you're going to have to write a little routine to close your > rings... it looks like the WKB emitter is hard-coded to error out when > asked to serialize broken things (hm I thought this was changed, > the neverending story...) For what its worth, I am using "POSTGIS="1.5.3" GEOS="3.3.0-CAPI-1.7.0" PROJ="Rel. 4.7.1, 23 September 2009" LIBXML="2.7.8" USE_STATS" As mentioned in my reply to Ben Madin's suggestion, when I run the following SELECT gid FROM data WHERE st_isclosed(the_geom) IS FALSE; I get no results. > > You can patch it your self by changing this line > > http://trac.osgeo.org/postgis/browser/tags/1.5.3/postgis/lwgeom_inout.c#L307 > > from PARSER_CHECK_ALL to PARSER_CHECK_NONE > > P. > > On Thu, Aug 18, 2011 at 9:19 AM, Mr. Puneet Kishor > wrote: >> >> I loaded a bunch of data (that came from ArcMap) into PostGIS (1.5.3) via >> shp2pgsql and am trying to draw it with MapServer 6.0.1. I get >> >>> msDrawMap(): Image handling error. Failed to draw layer named 'foo'. >>> msPostGISLayerWhichShapes(): Query error. Error (ERROR: geometry contains >>> non-closed rings ) >> >> >> Many thanks in advance for your suggestions. >> >> -- >> Puneet Kishor >> ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users
Re: [postgis-users] ERROR: geometry contains non-closed rings
Ben, On Aug 18, 2011, at 10:04 PM, Ben Madin wrote: > SELECT gid, st_isvalidreason(the_geom), st_summary(the_geom) FROM data WHERE > st_isclosed(the_geom) is FALSE; I am not entirely sure what the above was supposed to accomplish (I am assuming it would have given me the reason for features being invalid), however, I ran the query and I got 0 (zero) rows. Puneet. ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users
Re: [postgis-users] ERROR: geometry contains non-closed rings
G'day Puneet, Maybe you could start with : SELECT gid, st_isvalidreason(the_geom), st_summary(the_geom) FROM data WHERE st_isclosed(the_geom) is FALSE; cheers Ben On 19/08/2011, at 12:19 AM, Mr. Puneet Kishor wrote: > > I loaded a bunch of data (that came from ArcMap) into PostGIS (1.5.3) via > shp2pgsql and am trying to draw it with MapServer 6.0.1. I get > >> msDrawMap(): Image handling error. Failed to draw layer named 'foo'. >> msPostGISLayerWhichShapes(): Query error. Error (ERROR: geometry contains >> non-closed rings ) > > > Many thanks in advance for your suggestions. > > -- > Puneet Kishor > > ___ > postgis-users mailing list > postgis-users@postgis.refractions.net > http://postgis.refractions.net/mailman/listinfo/postgis-users ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users
Re: [postgis-users] ERROR: geometry contains non-closed rings
I think you're going to have to write a little routine to close your rings... it looks like the WKB emitter is hard-coded to error out when asked to serialize broken things (hm I thought this was changed, the neverending story...) You can patch it your self by changing this line http://trac.osgeo.org/postgis/browser/tags/1.5.3/postgis/lwgeom_inout.c#L307 from PARSER_CHECK_ALL to PARSER_CHECK_NONE P. On Thu, Aug 18, 2011 at 9:19 AM, Mr. Puneet Kishor wrote: > > I loaded a bunch of data (that came from ArcMap) into PostGIS (1.5.3) via > shp2pgsql and am trying to draw it with MapServer 6.0.1. I get > >> msDrawMap(): Image handling error. Failed to draw layer named 'foo'. >> msPostGISLayerWhichShapes(): Query error. Error (ERROR: geometry contains >> non-closed rings ) > > > Many thanks in advance for your suggestions. > > -- > Puneet Kishor > > ___ > postgis-users mailing list > postgis-users@postgis.refractions.net > http://postgis.refractions.net/mailman/listinfo/postgis-users > ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users
[postgis-users] ERROR: geometry contains non-closed rings
I loaded a bunch of data (that came from ArcMap) into PostGIS (1.5.3) via shp2pgsql and am trying to draw it with MapServer 6.0.1. I get > msDrawMap(): Image handling error. Failed to draw layer named 'foo'. > msPostGISLayerWhichShapes(): Query error. Error (ERROR: geometry contains > non-closed rings ) Many thanks in advance for your suggestions. -- Puneet Kishor ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users