[R-sig-Geo] [Qgis-user] spatial join, many to 1

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Mon Oct 22 22:02:11 CEST 2012


On Mon, Oct 22, 2012 at 7:52 PM, Frazier, Tyler James
<tyler.j.frazier at tu-berlin.de> wrote:
> Hi Edzer and list,
>
> Thanks for the package, the command over() essentially achieves my intended result, which is to overlay a set of (2500) points onto a set of (1000) polygons where each polygon receives all of the attribute data from each of the points located within its boundary.

 Each polygon can't [easily] 'receive' the attributes from a differing
number of points. The SpatialPolygonsDataFrame has one polygonal
feature related to one row in the data frame. You could have one
polygonal feature for each point, but that would end up as a massive
duplication of the polygonal data.

 It would seem to be better to create a new *point* data set, where
each row of the point data frame is augmented with the information
from the polygon in which it resides. This gives you something like an
ID variable that relates the points to the polygons in the manner of a
database id field.

 Overall, it really depends on what you want to do. If you want to
draw maps of polygons based on some aggregate function of the points
within, then that's a question of doing something like a 'tapply' on
the points using the polygons each point is in as a factor.

Barry



More information about the R-sig-Geo mailing list