Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- no. table_id value
- 1. a11 123
- 2. a12 456
- 3. a14 789
- no. polygon_id
- 1. a11
- 2. a12
- 3. a13
- 4. a14
- 5. a15
- no. id value
- 1. a11 123
- 2. a12 456
- 3. a13 0
- 4. a14 789
- 5. a15 0
- #trying to merge
- joined <- merge(table,polygons, by.x="table_id", by.y="polygons_id",all=T)
- ## overwrite the file with this new copy
- library(foreign)
- write.dbf(joined, "Polygons_R.dbf")
- Ward_polygons <- readShapePoly(fn="Polygons_R")
- Error in `row.names<-.data.frame`(`*tmp*`, value = value) :
- invalid 'row.names' length
- polygons$polygons_id<-(table)
- Error in `[[<-.data.frame`(`*tmp*`, name, value = c(1, 2, 1, 2, 9, 8, :
- replacement has 1309 rows, data has 2490
- library('rgdal')
- myShp <- readOGR(dsn, layer)
- myShp@data <- merge(x=myShp@data, y=myTable,
- by.x="table_id", by.y="polygons_id", all.x=TRUE)
- myShp@data$value[which(is.na(myShp@data$value))] <- 0
Add Comment
Please, Sign In to add comment