Ok, I'll send the needed WKTs and my query, as Martin Said. But I have to talk with my supervisor, because I've some doubts about data's privacy. If is useful, I tested the method "ST_isvalid" with the multipolygon and returns "false". Maybe the multipolygon is not closed? I loaded the data from a shapefile. Is it possible to create a "non-valid" multipolygon? Does PostGIS accept this?<br>
<br>
Ok, being even more specific. I'm working with data about Spain. I have a HUGE multipolygon that represents "water" (this is, the coasts around Spain and its islands). Then, the "holes" inside this multypolygon have the shape of Spain, Balearic Islands and Canary Islands. Of course, I have more multipolygons that represent "forests", "airports", "cities", etc, that fit into these holes.<br>
<br>Really, my problem is with some points that belong to an airport in an island. Using "ST_Within" and "ST_Contains", the result is that these points belong to the multipolygon "airport" and multipolygon "water" at same time. Obviously, the island (and its airport) is surrounded by water, but the airport's points shouldn't be part of the multopolygon "water". And, as I said, when I apply "ST_isvalid" to the multipolygon "water", returns false. Maybe is not closed?<br>
<br>Oh, btw, what's the difference between "ST_Within" and "Within". Does "ST_Within" use index instead of geometry? Am I right?<br><br>Many thanks, I'll provide more data asap<br><br>
<div class="gmail_quote">On Tue, May 5, 2009 at 6:24 PM, Paul Ramsey <span dir="ltr"><<a href="mailto:pramsey@opengeo.org">pramsey@opengeo.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
If ST_Contains() is returning both polygons then there's probably<br>
something wrong with the forest polygon (it doesn't have a hole, or it<br>
has both a polygon that has a hole and another component that *is* the<br>
hole, etc).<br>
<font color="#888888"><br>
P<br>
</font><div><div></div><div class="h5"><br>
On Tue, May 5, 2009 at 9:19 AM, Martin Davis <<a href="mailto:mbdavis@refractions.net">mbdavis@refractions.net</a>> wrote:<br>
> Polygons do not contain their holes. For a point P in a MultiPolygon M<br>
> which is inside a hole in one of the component Polygons you should have:<br>
><br>
> ST_within(P, M) = false<br>
> ST_contains(M, P) = false<br>
><br>
> Best to post your WKT and your query to confirm that's the problem.<br>
><br>
> Jorge wrote:<br>
>><br>
>> Hello,<br>
>><br>
>> I have a question. If a multipolygon has inner "holes", are these holes<br>
>> part of the multipolygon? I mean, if I want to check if a given point is<br>
>> inside of a multipolygon (using "within" or "contains") and this point<br>
>> is in the hole, should "within" and "contains" return "true"?<br>
>><br>
>> Being more specific, I have a multypolygon that represents a forest, in<br>
>> a map. This multipolygon has a hole inside. Then, I have another<br>
>> multipolygon that fits exactly into the hole, and represents an airport.<br>
>> If I select a point from the airport, this point is inside the second<br>
>> multipolygon, of course, but should it be inside the first one too?<br>
>> Because my problem is that I have to decide if the point is part of the<br>
>> airport or part of the forest, and "within" and "contains" methods<br>
>> return both multipolygon, instead of only the second one (the airport).<br>
>><br>
>> Maybe is more clear with an image:<br>
>> <a href="http://www.nebulared.com/tmp_geo/multipolygon.jpg" target="_blank">http://www.nebulared.com/tmp_geo/multipolygon.jpg</a><br>
>><br>
>> Thanks in advance!<br>
>><br>
>> Regards<br>
>> Jorge<br>
>> _______________________________________________<br>
>> postgis-users mailing list<br>
>> <a href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a><br>
>> <a href="http://postgis.refractions.net/mailman/listinfo/postgis-users" target="_blank">http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br>
>><br>
>><br>
><br>
> --<br>
> Martin Davis<br>
> Senior Technical Architect<br>
> Refractions Research, Inc.<br>
> (250) 383-3022<br>
><br>
> _______________________________________________<br>
> postgis-users mailing list<br>
> <a href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a><br>
> <a href="http://postgis.refractions.net/mailman/listinfo/postgis-users" target="_blank">http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br>
><br>
_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a><br>
<a href="http://postgis.refractions.net/mailman/listinfo/postgis-users" target="_blank">http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br>
</div></div></blockquote></div><br>