On Tue, 1 Jan 2008, Takatsugu Kobayashi wrote: > Hi > > Please forgive me if I am asking a simple question. > > I would like to add values in a column vector to readShapePoly() object > and show a map based on these values using spplot() or addPoly(). > > Basically, my raw data are employment census data with the coordinates > (X,Y). > > tmp1 <- read.csv("tmp1.csv",header=T) > > names(tmp1) > [1] "TAZ" "X" "Y" > [4] "X_UTM" "Y_UTM" "Perimeter" > [7] "Area" "in.n" "D_mean.dist" > [10] "D_median.dist" "D_mean.mean.time" "D_mean.median.time" > [13] "out.n" "O_mean.dist" "O_median.dist" > [16] "O_mean.mean.time" "O_mean.median.time" > > > map <- readShapePoly("Akron",proj4string=CRS("+proj=longlat > +datum=NAD27")) > names(map) > > > [1] "SOURCELYR" "SHAPECODE" "COUNTY" "SHORTLAB" "LONGLAB" > "X" > [7] "Y" "X_UTM" "Y_UTM" "Perimeter" "Area" > > tmp1/tmp2 and map have the same nrows and the same coordinates (X,Y). > > Any suggestions? Should I modify .dbf files before loading .shp files?
Look at ?"spCbind-methods", these methods are in the maptools package. The key thing is to make sure that the row names of tmp1 and tmp1 match those of slot(map, "data"), which is also a data frame. They will be re-ordered if need be, but must agree. You will see that match() is used in the example on the help page. In the example, the IDvar= argument is used in readShapePoly(), but you can also use spChFIDs-methods for changing the IDs. Roger > Or are there functions like join_table in ArcGIS? Or should I convert > tmp1 into a polypoint object and overlay it on map? > > Thank you very much. > > Takatsugu > > _______________________________________________ > R-sig-Geo mailing list > R-sig-Geo@stat.math.ethz.ch > https://stat.ethz.ch/mailman/listinfo/r-sig-geo > -- Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: [EMAIL PROTECTED] _______________________________________________ R-sig-Geo mailing list R-sig-Geo@stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo