0
## Importing map of Brazil
map <- readOGR ("UFEBRASIL.shp")
class (map)
plot (map, axes = F)
title ("")

## importing file with case data
data <- read.csv2 ("cases.csv")

# Recognizing the names of states as a character
map @ data $ NM_ESTADO <- as.character (map @ data $ NM_ESTADO)
map @ data $ NM_ESTADO

# Ordering the data correctly to match the order of the neighborhoods in the shape and attribute table.
head (map @ data)
head
ind <- match (map @ data $ ID, data $ ID)
ind
# Correcting accents in shape
proj4string (map) <- CRS ("+ proj = longlat + datum = WGS84 + no_defs")
Encoding (map $ NM_ESTADO) <- "UTF-8"
map $ CD_GEOCODU [is.na (map $ CD_GEOCODU)] <- 0
map1 <- spTransform (map, CRS ("+ proj = longlat + ellps = GRS80"))
summary (map1)
map1 $ NM_ESTADO

# Concatenating the map with the database
data <- data [ind,]
row.names (data) <- map1 $ NM_ESTADO
map1 <- spCbind (map1, data)

In this last line of command of the following error:

Error in spCbind(mapa1, dados) : row names not identical

closed as off-topic by Vince, Fran Raga, Jochen Schwarze, Spacedman, aldo_tapia May 27 at 16:50

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "When seeking help to debug/write/improve code always provide the desired behavior, a specific problem/error and the shortest code (as formatted text, not pictures) needed to reproduce it in the question body. Providing a clear problem statement and a code attempt helps others to help you." – Vince, Fran Raga, Jochen Schwarze, Spacedman, aldo_tapia
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    Welcome to GIS SE. As a new user, please take the Tour. This is effectively a "Wall of code" post, with no description of the problem and inputs before diving into code. In the parlance of the close reason, "Providing a clear problem statement and a code attempt helps others to help you." Please Edit the question to frame the problem and inputs. – Vince May 26 at 22:00
0

As a test that you haven't got the rows in the wrong order, spCbind tests the equality of the row names of the arguments. If they don't match it will stop:

> d = data.frame(ZZ=runif(56),AA=runif(56))
> ss = spCbind(scot_BNG,d) # scot_BNG from example(readOGR)
Error in spCbind(scot_BNG, d) : row names not identical

If you want to override this and you are sure the rows are in the right order, reassign the row names of the second argument from the first:

> row.names(d) = row.names(scot_BNG)
> ss = spCbind(scot_BNG,d) # scot_BNG from example(readOGR)
> 

If the original row names are of use, store them as a column in d before reassigning them from the spatial object.

Not the answer you're looking for? Browse other questions tagged or ask your own question.