Hi all,

Thanks for all your help, Roger you were right!  The merge function looked
like it had done it fine but when I came to plot it the shapefile clearly
hadn't joined correctly.  I think this is some kind of bodge, but I've
managed to use the match() function to join the csv with the shapefile, then
use an if function along with gunioncascade to join the internal polygons
according to col_2.

Match code:
frame@data=gc[match(shape@data[,"Col_1"], csv[,"Col_1"]),]

Then for each higher level (Col_2):

TERRITORY1 <- gUnionCascaded(frame[ which(frame$TERR=='1'), ])
plot(TERRITORY1)

TERRITORY2 <- gUnionCascaded(frame[ which(frame$TERR=='2'), ])
plot(TERRITORY2)

I'm hoping I can now use a concatenation of "TERRITORY1", "TERRITORY2" etc.
to map all of it, or single ones if I want.  Just hoping the rest of my data
from the csv is all joined on correctly.  Working on ggplot2 map now. 
Thanks for everyone's help, just thought I'd update this!



--
View this message in context: 
http://r-sig-geo.2731867.n2.nabble.com/Merging-shapefiles-and-csv-tp7586839p7586852.html
Sent from the R-sig-geo mailing list archive at Nabble.com.

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to