[postgis-users] Newbie question - Transfer attributes from onefeature to another

Obe, Regina robe.dnd at cityofboston.gov
Mon Oct 6 04:55:54 PDT 2008


Sindile,
 
If a polygon has one or more point features and you want to transfer the
attributes from the point feature to the polygon feature, then what do
you do in cases where there are multiple points in a polygon
 
would you
 
1) pick the first one you hit
2) Sum up, take the max etc. of each
3) Duplicate the poly for each point?
 
In all cases, you will want to do an intersect check
 
(solution 1)
SELECT DISTINCT ON(poly.gid) poly.gid, poly.the_geom, point.somefield1
As somefield1, point.somefield2 As somefield2
FROM
table1 As poly INNER JOIN table2 As point
ON ST_Intersects(poly.the_geom, point.the_geom)
ORDER BY poly.gid, point.gid;
 
(solution to 2 would look something like this)
SELECT poly.gid, poly.the_geom, SUM(point.somefield1) As totsomefield1,
MAX(point.somefield2) As maxsomefield2
FROM
table1 As poly INNER JOIN table2 As point
ON ST_Intersects(poly.the_geom, point.the_geom)
GROUP BY poly.gid, poly.the_geom;
 
(solution to 3)
  
SELECT poly.gid, poly.the_geom, point.somefield1 As somefield1,
point.somefield2 As somefield2
FROM
table1 As poly INNER JOIN table2 As point
ON ST_Intersects(poly.the_geom, point.the_geom)
 
Hope that helps,
Regina
 
 
 
 

________________________________

From: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of
Intengu Technologies
Sent: Monday, October 06, 2008 4:47 AM
To: PostGIS Users Discussion
Subject: [postgis-users] Newbie question - Transfer attributes from
onefeature to another


I have a polygon (table1) and a point (table2) feature and would want to
transfer attributes from the point feature to the polygon feature based
on whether the point feature is completely enclosed by the polygon
feature.
The polygon feature can have one or more point features.

How do i transfer the attributes.


-- 
Sindile Bidla



-----------------------------------------
The substance of this message, including any attachments, may be
confidential, legally privileged and/or exempt from disclosure
pursuant to Massachusetts law. It is intended
solely for the addressee. If you received this in error, please
contact the sender and delete the material from any computer.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20081006/2de34ea9/attachment.html>


More information about the postgis-users mailing list