[postgis-users] Newbie question - Transfer attributes fromonefeature to another
Obe, Regina
robe.dnd at cityofboston.gov
Mon Oct 6 06:52:18 PDT 2008
You mean like to concatenate all the point field information in one
field in the poly. Also the below I gave was to create a new set of
data. To update a poly field by concatenating all the field information
from the points. Try something like
UPDATE table1
SET somefield = array_to_string(ARRAY(SELECT DISTINCT point.somefield
FROM table2 As point
WHERE point.somefield > '' AND
ST_Intersects(table1.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 8:08 AM
To: PostGIS Users Discussion
Subject: Re: [postgis-users] Newbie question - Transfer attributes
fromonefeature to another
Regina,
Solution 3 is would work fine, but was hoping for a solution to transfer
the attributes into one field without duplicating the poly.
Thanks for the pointer.
2008/10/6 Obe, Regina <robe.dnd at cityofboston.gov>
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.
________________________________
Help make the earth a greener place. If at all possible resist
printing this email and join us in saving paper.
_______________________________________________
postgis-users mailing list
postgis-users at postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users
--
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/7c12f115/attachment.html>
More information about the postgis-users
mailing list