[postgis-users] relationship functions not working well

Martin Davis mbdavis at refractions.net
Thu Dec 4 17:23:46 PST 2008


It sounds like you want the relationship "intersects-and-not-touches" - 
does that sound right?

This relation has quite a complex expression in terms of the IM pattern 
languge.  It is:

[T********]  or [*T*******] or [***T*****] or [****T****]
and not ( [FT*******] or [F**T*****] or [F***T****] )

This is equivalent to:

not ([FF*FF****] or [FT*******] or [F**T*****] or [F***T****] )

Unfortunately I don't think there is a "closed-form" or single-string 
pattern for this which can be used with the boolean relate function.  
The intersection-matrix-returning version of relate will be needed - but 
even then testing these patterns is going to be tricky.

I've had some thoughts in the past that what is required is a more 
complete pattern-matching language for relate, so that the above logic 
could be specified and evaluated. Or, a matches_IM_pattern function 
could be provided, which would allow evaluation of boolean combinations 
of patterns against the IM string returned from relate.

Another option would be for PostGIS to provide some standard "combined 
name relationship" functions, such as "intersects_not_touches".  

Of course you can also evaluate a boolean expression containing both 
predicates - but this is less efficient.

Hope this helps...

William Kyngesburye wrote:
> 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
>
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>

-- 
Martin Davis
Senior Technical Architect
Refractions Research, Inc.
(250) 383-3022




More information about the postgis-users mailing list