Error in spCbind(GA0, data) : row names not identical

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Error in spCbind(GA0, data) : row names not identical

R-sig-geo mailing list
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
        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: Error in spCbind(GA0, data) : row names not identical

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


        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo