HI,Could some one help? this newbie in fixing the spCbind problem encountered below?>names(data)?"county"? ? "y"? ? ? ? ?"x"? ? ? ? ?"Latitude"? "Longitude"
GA <- map("county", "georgia", plot=FALSE, fill=TRUE)
cntys <- tolower(as.character(data$county))GA$names <- substring(GA$names, 9, nchar(GA$names))match(cntys, GA$names)##It does? match!#######################################GA <- map2SpatialPolygons(GA, GA$names)proj4string(GA) <- CRS("+proj=longlat")row.names(data) <- cntysGA0 <- SpatialPolygonsDataFrame(GA, data=data.frame(ID=1:159,row.names=row.names(GA)))GA1 <- spCbind(GA0, data)> GA1 <- spCbind(GA0, data)Error in spCbind(GA0, data) : row names not identical>?Thanks n advance,
Marvin
Error in spCbind(GA0, data) : row names not identical
2 messages · Marvin Sharma, Bede-Fazekas Ákos
Hi Marvin, I think it should be better to post more information on the error, which could help us to help you. And while you try to get these additional infos, you might find the solution to your problem. I think, running row.names(GA0) row.names(data) all.equal(row.names(GA0), row.names(data)) row.names(GA0)[row.names(GA0) != row.names(data)] row.names(data)[row.names(GA0) != row.names(data)] may help you to start searching the cause of the error. (Which is simply connected to the spelling of "De Kalb", and has nothing to do with spatial data and R...) > row.names(GA0)[row.names(GA0) != row.names(data)] [1] "de kalb" "decatur" > row.names(data)[row.names(GA0) != row.names(data)] [1] "decatur" "dekalb" Have a nice day, ?kos 2017.10.22. 14:48 keltez?ssel, Marvin Sharma ?rta:
HI, Could some one help? this newbie in fixing the spCbind problem encountered below?
names(data)
?"county"? ? "y" ? ? ? ?"x"? ? ? ? ?"Latitude"? "Longitude"
GA <- map("county", "georgia", plot=FALSE, fill=TRUE)
cntys <- tolower(as.character(data$county))
GA$names <- substring(GA$names, 9, nchar(GA$names))
match(cntys, GA$names)##It does? match!
#######################################
GA <- map2SpatialPolygons(GA, GA$names)
proj4string(GA) <- CRS("+proj=longlat")
row.names(data) <- cntys
GA0 <- SpatialPolygonsDataFrame(GA,
data=data.frame(ID=1:159,row.names=row.names(GA)))
GA1 <- spCbind(GA0, data)
GA1 <- spCbind(GA0, data)
Error in spCbind(GA0, data) : row names not identical
Thanks n advance, Marvin