[postgis-users] relationship functions not working well

Nicolas Ribot nicky666 at gmail.com
Thu Dec 4 12:11:19 PST 2008


> When I was debugging my invalid geometry problem, I needed to select a small
> area to view.  The data is divided up into 1 degree tiles (it's the SRTM
> SWBD shapefiles imported).  I figured selecting by whole integer degrees
> would be simple to deal with.
>
> I started with st_overlaps(), as it was mentioned in the wiki I think, or
> somewhere online (this was a few weeks ago, and don't remember the details).
>  But it was not selecting very much at all in a large area.  I looked at the
> PostGIS documentation to see what other functions would work, but their
> descriptions are not plain english and and tried them all.  And there was a
> pointer to:
>
> http://lin-ear-th-inking.blogspot.com/2007/06/subtleties-of-ogc-covers-spatial.html
>
> that helped a little.  But none of the ones I tried gave me what I want -
> polygon areas  completely inside the box boundary and area, and not polygons
> where only the boundary touches the box boundary.
>
> Snapshots:
>
> http://www.kyngchaos.com/wiki/gallery:gis:temp:index
>
> ST_Overlaps() -- only polygons selected where their boundaries touch the box
> boundary and any part of the polygon area is inside the box.  I get none
> that are completely within but not touching are selected.
>
> ST_Intersects() -- all polygons selected where //any// part of the polygon
> (boundary and inside) are in or touch //any// part of the box, though it
> seems to have missed some from the upper-right neighboring cells.  A lot
> more than I want.
>
> ST_CoveredBy() -- only polygons where the boundary //and// area are
> completely inside only the area of the box and not touching the box
> boundary.  I don't get the polys touching the box edge.
>
> ST_Within() -- similar to st_coveredby, except that it only seems to look at
> the outer boundary of the polygons, and that upper-right corner polygon is
> actually an invalid polygon where the "outer" polygon is a "hole" polygon
> (not visible here), thus inside and not touching the box boundary.
>
>
> Did I miss an obvious function, or is there something that will get what I
> want?  hmmm, maybe a combination (but would that slow it down a lot)?
>

Hi William,

Did you try st_relate() the the appropriate DE-9IM matrix ?
I can't give you the pattern that will express your need exactly as I
read your email rapidely, but looking here may surely help:
http://postgis.refractions.net/documentation/manual-svn/ST_Relate.html
(also following the  intersectionPatternMatrix link)

This presentation may also help:
http://www.foss4g2007.org/presentations/view.php?abstract_id=117

Nicolas



More information about the postgis-users mailing list