[postgis-users] Identity Overlay

Martin Davis mbdavis at refractions.net
Thu Nov 23 08:49:05 PST 2006


You may want to use the intersects() predicate rather than contains() 
for this query.  The reasons are:

1) Technically, the OGC definition of contains implies that "polygons do 
not contain their boundary".  This means that the test 
poly.contains(pt)  produces a false result if pt lies exactly on the 
boundary of the polygon.  Usually this is not the result that is 
desired.  intersects() does not have this behaviour.  (It's also worth 
noting that JTS now offers a covers() and coverBy() predicates, which 
also have the expected behaviour.

2) Because of its simpler semantics, intersects is a bit easier to 
optimize, and hence may get more attention and get done sooner than 
contains.

Aaron Koning wrote:
> Hi All,
>
> I am trying to perform an identity overlay where each point in a point 
> layer gets a value from a polygon layer based on what polygon contains 
> the point. I have come up with the following query which is working 
> fairly well.
>      UPDATE point_layer SET b250k_tag = polygon_layer.b250k_tag WHERE 
> contains(polygon_layer.the_geom, point_layer.the_geom);
>
> I am just wondering if other people have performed identity like 
> overlays in PostGIS and is there a better / more efficient way to 
> perform them?
>
> Thanks,
> Aaron
>
> +-------------------------------------------------
> |  Aaron Koning
> |  Information Technologist
> |  Prince George, BC, Canada.
> +-------------------------------------------------
> |  Flexible Internet Spatial Template:
> |       http://fist-mapping.org
> +-------------------------------------------------
> ------------------------------------------------------------------------
>
> _______________________________________________
> 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