Guest User

Untitled

a guest
Jul 16th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. no. table_id value
  2. 1. a11 123
  3. 2. a12 456
  4. 3. a14 789
  5.  
  6. no. polygon_id
  7. 1. a11
  8. 2. a12
  9. 3. a13
  10. 4. a14
  11. 5. a15
  12.  
  13. no. id value
  14. 1. a11 123
  15. 2. a12 456
  16. 3. a13 0
  17. 4. a14 789
  18. 5. a15 0
  19.  
  20. #trying to merge
  21. joined <- merge(table,polygons, by.x="table_id", by.y="polygons_id",all=T)
  22. ## overwrite the file with this new copy
  23. library(foreign)
  24. write.dbf(joined, "Polygons_R.dbf")
  25.  
  26. Ward_polygons <- readShapePoly(fn="Polygons_R")
  27.  
  28. Error in `row.names<-.data.frame`(`*tmp*`, value = value) :
  29. invalid 'row.names' length
  30.  
  31. polygons$polygons_id<-(table)
  32.  
  33. Error in `[[<-.data.frame`(`*tmp*`, name, value = c(1, 2, 1, 2, 9, 8, :
  34. replacement has 1309 rows, data has 2490
  35.  
  36. library('rgdal')
  37. myShp <- readOGR(dsn, layer)
  38. myShp@data <- merge(x=myShp@data, y=myTable,
  39. by.x="table_id", by.y="polygons_id", all.x=TRUE)
  40.  
  41. myShp@data$value[which(is.na(myShp@data$value))] <- 0
Add Comment
Please, Sign In to add comment