[postgis-users] relationship functions not working well

William Kyngesburye woklist at kyngchaos.com
Thu Dec 4 10:17:00 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)?

-----
William Kyngesburye <kyngchaos*at*kyngchaos*dot*com>
http://www.kyngchaos.com/

[Trillian]  What are you supposed to do WITH a maniacally depressed  
robot?

[Marvin]  You think you have problems?  What are you supposed to do if  
you ARE a maniacally depressed robot?  No, don't try and answer, I'm  
50,000 times more intelligent than you and even I don't know the  
answer...

- HitchHiker's Guide to the Galaxy





More information about the postgis-users mailing list