Hi, Roberts,
In my last mail, I mentioned it works fine, but when I try write shape
file after merging it shows error. I think I need to define spatial
object or data frame after merging. I do not know how to do this.
Thanks again.
Zia
> poly.data1 = merge(poly.data, data.table, by="MUKEY" ,all.x = TRUE)
> names(poly.data1) # polygoan
[1] "MUKEY" "AREASYMBOL" "SPATIALVER" "MUSYM" "Sand"
[6] "Silt" "Clay" "pH" "CEC" "EC"
[11] "SAR" "CaCO3" "SOM" "BD" "AWC"
[16] "KSAT" "Kf" "Kw" "LL" "LEP"
>polyShp <- "D:/test/mapunit_poly.shp"
> writeOGR(poly.data1, dsn=polyShp, layer="mapunit_poly", driver="ESRI
Shapefile")
Error in writeOGR(poly.data1, dsn = polyShp, layer = "mapunit_poly",
driver = "ESRI Shapefile") :
obj of wrong class
Zia Ahmed wrote:
Thank you so much Roberts! it works.
Zia
Robert J. Hijmans wrote:
Zia, something like this might work as long as MUKEY has no NA values:
poly.data = merge(poly.data, data.table, by="MUKEY" ,all.x = TRUE)
Robert
On Wed, Jan 27, 2010 at 1:58 PM, Zia Ahmed <z...@cornell.edu> wrote:
I have created one data table and one polygon in R. Both have a
similar type
of column. I want to combine or join them with this column or field
("MUKEY"). Then I will convert this polygon as a ESRI shape file.
But when I used spCbind, I got error. I think i miss something
here.
Is there any way join attribute table with polygon? Thanks
Zia
poly.data1 <- spCbind(poly.data, data.table)
Error in spCbind(poly.data, data.table) : different numbers of rows
names(poly.data) # polygoan
[1] "AREASYMBOL" "SPATIALVER" "MUSYM" "MUKEY" >
names(data.table) #
data
[1] "MUKEY" "Sand" "Silt" "Clay" "pH" "CEC" "EC" "SAR"
"CaCO3"
[10] "SOM" "BD" "AWC" "KSAT" "Kf" "Kw" "LL" "LEP"
length(poly.data$MUKEY)
[1] 76969
length(data.table$MUKEY)
[1] 184
poly.data1 <- spCbind(poly.data, data.table)
combinedShp1 <- "D:/test/combined1.shp" writeOGR(poly.data1,
dsn=combinedShp1, layer="combined1", driver="ESRI Shapefile")
_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo