Re: [postgis-users] TopologyException and ST_Intersection

2012-06-26 Thread Sandro Santilli
On Mon, Jun 25, 2012 at 07:23:33PM -0400, jdmorgan wrote:
 Hi Sandro,
 
 Thanks for your reply.  Here is the PostGIS version we are using:
 POSTGIS=1.5.3 GEOS=3.3.1-CAPI-1.7.1 PROJ=Rel. 4.7.1, 23
 September 2009 LIBXML=2.7.6 USE_STATS
 
 Is it easy to upgrade the GEOS or the POSTGIS version for that
 matter?  What I mean is it an inplace upgrade?  We are running on a
 LINUX server (CENTOS).

Inplace upgrade of GEOS is straightforward: just grab 3.3.5, unpack,
build and install.

--strk;

 Sent from our free software
 http://www.gnu.org/philosophy/free-sw.html
___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


Re: [postgis-users] TopologyException and ST_Intersection

2012-06-25 Thread Nicolas Ribot
Hi,

Check the validity of input geometries with st_isValid() and
st_isValidReason() and if invalid objects are found, you can correct
them using st_makeValid()

Nicolas

On 25 June 2012 03:18, Derek Morgan jdmor...@unca.edu wrote:
 I am attempting to get the area of intersection between to vector
 polygon tables in PostGIS.  I am using the following SQL:

 SELECT ctys.fips,
       Sum(ST_Area(ST_Intersection(ctys.the_geom,pads.the_geom)))
 FROM counties4269 ctys,
     padus4269 pads
 WHERE ST_Overlaps(ctys.the_geom, pads.the_geom)
 GROUP by ctys.fips;

 However, my query returns the following error:  TopologyException:
 side location conflict at 1.66342e+06 1.99261e+06
 ERROR:  GEOS overlaps() threw an error!

 I am guessing that this has to do with some topology issues.  Any help
 or pointers would be greatly appreciated.

 Thanks,
 Derek
 ___
 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] TopologyException and ST_Intersection

2012-06-25 Thread jdmorgan

Hi Nicolas,
This is great.  However, we are running POSTGIS=1.5.3  Is this 
possible in this version?  If not, is there a workaround as I don't 
think we will be able to upgrade that quickely?


Thanks,
Derek
___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


Re: [postgis-users] TopologyException and ST_Intersection

2012-06-25 Thread Nicolas Ribot
 Hi Nicolas,
 This is great.  However, we are running POSTGIS=1.5.3  Is this possible in
 this version?  If not, is there a workaround as I don't think we will be
 able to upgrade that quickely?



Hi Derek

Yes indeed, there is a trick on postgis  2.0 to clean polygons: try
using st_buffer(geom, 0.0). This method is often able to rebuild a
valid polygon from an invalid one. I also saw on the list (and tested
myself) that st_buffer(st_buffer(geom, -1), 1) could clean some
polygons that are not cleaned with only a 0 unit buffer.

Nicolas
___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


Re: [postgis-users] TopologyException and ST_Intersection

2012-06-25 Thread Bob and Deb
People should be cautioned that some polygons might disappear when using a
buffer of 0.  Does Postgis 2.0 have this problem with makevalid?
On Jun 25, 2012 7:47 AM, Nicolas Ribot nicolas.ri...@gmail.com wrote:

  Hi Nicolas,
  This is great.  However, we are running POSTGIS=1.5.3  Is this
 possible in
  this version?  If not, is there a workaround as I don't think we will be
  able to upgrade that quickely?
 
 

 Hi Derek

 Yes indeed, there is a trick on postgis  2.0 to clean polygons: try
 using st_buffer(geom, 0.0). This method is often able to rebuild a
 valid polygon from an invalid one. I also saw on the list (and tested
 myself) that st_buffer(st_buffer(geom, -1), 1) could clean some
 polygons that are not cleaned with only a 0 unit buffer.

 Nicolas
 ___
 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] TopologyException and ST_Intersection

2012-06-25 Thread jdmorgan

Nicolas,


This is awesome feedback and I really appreciate it as I am new to 
PostGIS.  However, I still get the following after creating new 
populated tables via the st_buffer(geom, 0.0) or the 
st_buffer(st_buffer(geom, -1), 1).  Any other ideas?



NOTICE:  TopologyException: side location conflict at 1.66342e+06 
1.99261e+06

ERROR:  GEOS overlaps() threw an error!


Cheers,
Derek


___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


Re: [postgis-users] TopologyException and ST_Intersection

2012-06-25 Thread Sandro Santilli
On Mon, Jun 25, 2012 at 09:15:21AM -0700, Bob and Deb wrote:
 People should be cautioned that some polygons might disappear when using a
 buffer of 0.  Does Postgis 2.0 have this problem with makevalid?

No, ST_MakeValid retains all vertices.

--strk;

 Sent from our free software
 http://www.gnu.org/philosophy/free-sw.html
___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


Re: [postgis-users] TopologyException and ST_Intersection

2012-06-25 Thread Sandro Santilli
On Mon, Jun 25, 2012 at 01:47:22PM -0400, jdmorgan wrote:
 
 This is awesome feedback and I really appreciate it as I am new to
 PostGIS.  However, I still get the following after creating new
 populated tables via the st_buffer(geom, 0.0) or the
 st_buffer(st_buffer(geom, -1), 1).  Any other ideas?
 
 NOTICE:  TopologyException: side location conflict at 1.66342e+06
 1.99261e+06
 ERROR:  GEOS overlaps() threw an error!

Which version of GEOS do you have ? SELECT postgis_full_version();

Try upgrading to latest (3.3.5) 
If it still fails consider reducing the input pair till it's small
enough to be attached as HEXWKB to a ticket.

As a workaround you could try shaking the vertices with something
like ST_SnapToGrid (and maybe ST_UnaryUnion on the result to ensure
validity on collapse).

--strk;

 Sent from our free software
 http://www.gnu.org/philosophy/free-sw.html
___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


Re: [postgis-users] TopologyException and ST_Intersection

2012-06-25 Thread jdmorgan

Hi Sandro,

Thanks for your reply.  Here is the PostGIS version we are using:  
POSTGIS=1.5.3 GEOS=3.3.1-CAPI-1.7.1 PROJ=Rel. 4.7.1, 23 September 
2009 LIBXML=2.7.6 USE_STATS


Is it easy to upgrade the GEOS or the POSTGIS version for that matter?  
What I mean is it an inplace upgrade?  We are running on a LINUX server 
(CENTOS).


Cheers,
Derek
___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


[postgis-users] TopologyException and ST_Intersection

2012-06-24 Thread Derek Morgan
I am attempting to get the area of intersection between to vector
polygon tables in PostGIS.  I am using the following SQL:

SELECT ctys.fips,
   Sum(ST_Area(ST_Intersection(ctys.the_geom,pads.the_geom)))
FROM counties4269 ctys,
 padus4269 pads
WHERE ST_Overlaps(ctys.the_geom, pads.the_geom)
GROUP by ctys.fips;

However, my query returns the following error:  TopologyException:
side location conflict at 1.66342e+06 1.99261e+06
ERROR:  GEOS overlaps() threw an error!

I am guessing that this has to do with some topology issues.  Any help
or pointers would be greatly appreciated.

Thanks,
Derek
___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users