<html xmlns:m="http://schemas.microsoft.com/office/2004/12/omml">
<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 10 (filtered)">
<style>
<!--a:link
{mso-style-priority:99;}
span.MSOHYPERLINK
{mso-style-priority:99;}
a:visited
{mso-style-priority:99;}
span.MSOHYPERLINKFOLLOWED
{mso-style-priority:99;}
/* Font Definitions */
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
{font-family:Calibri;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:Calibri;}
a:link, span.MsoHyperlink
{color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{color:purple;
text-decoration:underline;}
span.EmailStyle17
{font-family:Calibri;
color:windowtext;}
span.EmailStyle18
{font-family:Arial;
color:navy;}
@page Section1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
{page:Section1;}
-->
</style>
</head>
<body lang=EN-US link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>I have experienced this same difficulty
when using the simplify() function. I can eliminate some of them by using
a smaller tolerance, although it seems that there is something in the isValid
routine that OKs records that have some problems. I have found that if I
use only the buffer(the_geom,0) I can obtain valid shapes in all cases (at
least all that I have tried, which is around 3,000 shapes).</span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'> </span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>If you really need to simplify, perhaps
you can alter the order in which you are doing your operations, i.e., buffer
first, then simplify(). While this is not a fix to the underlying
troubles, it may get you up and running.</span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'> </span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>HTH,</span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'> </span></font></p>
<div>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Robert W. Burgholzer</span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Surface Water Modeler</span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Office of Water Supply and Planning</span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Virginia Department of Environmental
Quality</span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><a
href="mailto:rwburgholzer@deq.virginia.gov">rwburgholzer@deq.virginia.gov</a></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>804-698-4405</span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Open Source Modeling Tools:</span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><a
href="http://sourceforge.net/projects/npsource/">http://sourceforge.net/projects/npsource/</a></span></font></p>
<p class=MsoNormal><font size=2 face=Calibri><span style='font-size:11.0pt'> </span></font></p>
</div>
<p class=MsoNormal style='margin-left:.5in'><font size=2 face=Tahoma><span
style='font-size:10.0pt;font-family:Tahoma'>-----Original Message-----<br>
<b><span style='font-weight:bold'>From:</span></b>
postgis-users-bounces@postgis.refractions.net
[mailto:postgis-users-bounces@postgis.refractions.net] <b><span
style='font-weight:bold'>On Behalf Of </span></b>James DeMichele<br>
<b><span style='font-weight:bold'>Sent:</span></b> Friday, December 28, 2007
2:25 PM<br>
<b><span style='font-weight:bold'>To:</span></b>
postgis-users@postgis.refractions.net<br>
<b><span style='font-weight:bold'>Subject:</span></b> [postgis-users] ST_contains()
throws an error</span></font></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 face=Calibri><span
style='font-size:11.0pt'> </span></font></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 face=Calibri><span
style='font-size:11.0pt'>Hi,</span></font></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 face=Calibri><span
style='font-size:11.0pt'>I have a table with 27000 records and each record has
2 geometry columns. The first column has an original MULTIPOLYGON (named
original_poly), and the second column has some tweaks (buffer and
simplification) applied to the original data, and is also stored as a
MULTIPOLYGON (named new_poly).</span></font></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 face=Calibri><span
style='font-size:11.0pt'> </span></font></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 face=Calibri><span
style='font-size:11.0pt'>I want to get the list of these rows where the
new_poly does NOT contain the original_poly. The first time I ran it, I got
this: “ERROR: GEOS contains() threw an error!”</span></font></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 face=Calibri><span
style='font-size:11.0pt'> </span></font></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 face=Calibri><span
style='font-size:11.0pt'>So, then I thought that maybe some of the polygons
were not valid. There were 6 invalid polygons, so then I tried running this
query:</span></font></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 face=Calibri><span
style='font-size:11.0pt'> </span></font></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 face=Calibri><span
style='font-size:11.0pt'>select count(*) </span></font></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 face=Calibri><span
style='font-size:11.0pt'>from temp_places_buffer </span></font></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 face=Calibri><span
style='font-size:11.0pt'>where(st_isvalid(new_poly) = true and
st_isvalid(redfin_poly) = true) </span></font></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 face=Calibri><span
style='font-size:11.0pt'>and not st_contains(t1.new_poly, t1.redfin_poly);</span></font></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 face=Calibri><span
style='font-size:11.0pt'> </span></font></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 face=Calibri><span
style='font-size:11.0pt'>Unfortunately, I still get this error:</span></font></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 face=Calibri><span
style='font-size:11.0pt'> </span></font></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 face=Calibri><span
style='font-size:11.0pt'>ERROR: GEOS contains() threw an error!</span></font></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 face=Calibri><span
style='font-size:11.0pt'> </span></font></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 face=Calibri><span
style='font-size:11.0pt'>What are possible reasons that this would still be
throwing an error, other than invalid polygons, since the query should now only
be calculating st_contains on valid polygons?</span></font></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 face=Calibri><span
style='font-size:11.0pt'> </span></font></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 face=Calibri><span
style='font-size:11.0pt'>I am running this version:</span></font></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 face=Calibri><span
style='font-size:11.0pt'> </span></font></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 face=Calibri><span
style='font-size:11.0pt'>
postgis_version</span></font></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 face=Calibri><span
style='font-size:11.0pt'>---------------------------------------</span></font></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 face=Calibri><span
style='font-size:11.0pt'> 1.3 USE_GEOS=1 USE_PROJ=1 USE_STATS=1</span></font></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 face=Calibri><span
style='font-size:11.0pt'> </span></font></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 face=Calibri><span
style='font-size:11.0pt'>Thanks.</span></font></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 face=Calibri><span
style='font-size:11.0pt'> </span></font></p>
<p class=MsoNormal style='margin-left:.5in'><font size=2 face=Calibri><span
style='font-size:11.0pt'>-James</span></font></p>
</div>
</body>
</html>