Hi Barry,

Really what I am trying to do is link raw census DATA to an enumeration area MAP, which spatially represents different aggregations of those observations.  In order to do so, on the MAP side, I first want to join a point shape file which has all of the town names to an enumeration area shape file, which is missing those names.

Previously, when I did this on the DATA side I used the following command ---

enum_areas <- aggregate(localities_region1,by=list(localities_region1$ea_code), FUN=unique)

and when an enumeration area had more then one town located within it, R created a field within a row as follows ---

c("NEW-TOWN WHARF", "BALIBANGARA", "BOLENWO").

On the MAP side, it appears when I use the over() command, like so ---

spatial_join <- over(ea_map, towns)

over() supplies only the name of the first town listed within that enumeration area and ignores/omits the remainder.  If over() created all of the names in a similar manner as aggregate(), couldn't I then use

map <- SpatialPolygonsDataFrame(ea_map,spatial_join)

in order to create my map?  What do you think?

I suppose it would be possible to achieve the same using postGIS and some commands there, but would rather take a route within R.  I haven't thought about how to use tapply() yet.

Thanks!
Ty


On Oct 22, 2012, at 10:02 PM, Barry Rowlingson wrote:

On Mon, Oct 22, 2012 at 7:52 PM, Frazier, Tyler James
<tyler.j.frazier@tu-berlin.de<mailto:tyler.j.frazier@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

-----
Tyler Frazier
Department of Transportation Planning and Telematics
Technical University Berlin
http://www.vsp.tu-berlin.de/





	[[alternative HTML version deleted]]

