Guest User

Untitled

a guest
Feb 21st, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. #Polygon
  2. x <- structure(list(AREA = 1489841.35074, geometry = structure(list(
  3. structure(list(structure(c(4371395.39166986, 4371395.39166986,
  4. 4372634.07252284, 4372634.07252284, 4371395.39166986, 5478810.68590502,
  5. 5480013.45040013, 5480013.45040013, 5478810.68590502, 5478810.68590502
  6. ), .Dim = c(5L, 2L))), class = c("XY", "POLYGON", "sfg"))), n_empty = 0L, crs = structure(list(
  7. epsg = NA_integer_, proj4string = "+proj=tmerc +lat_0=0 +lon_0=12 +k=1 +x_0=4500000 +y_0=0 +datum=potsdam +units=m +no_defs"), .Names = c("epsg",
  8. "proj4string"), class = "crs"), class = c("sfc_POLYGON", "sfc"
  9. ), precision = 0, bbox = structure(c(4371395.39166986, 5478810.68590502,
  10. 4372634.07252284, 5480013.45040013), .Names = c("xmin", "ymin",
  11. "xmax", "ymax"), class = "bbox"))), .Names = c("AREA", "geometry"
  12. ), row.names = c(NA, -1L), class = c("sf", "data.frame"), sf_column = "geometry", agr = structure(NA_integer_, class = "factor", .Label = c("constant",
  13. "aggregate", "identity"), .Names = "AREA"))
  14.  
  15. library(sf)
  16.  
  17. #distances for buffers "aggregate", "identity"), .Names = "AREA")) "aggregate", "identity"), .Names = "AREA")
  18. dist <- c(50,500,1000,3000)
  19.  
  20. #list holding the buffer rings
  21. lstbuffers <-list()
  22. for (i in seq(dist)){
  23. #first buffer
  24. if (i == 1){
  25. lstbuffers[[i]]<- st_buffer(x,dist[i])
  26.  
  27. }else{
  28. #next buffers as rings around the previous
  29. lstbuffers[[i]] <- st_difference(st_buffer(x,dist[i]),st_buffer(x, dist[i-1]))
  30. }
  31. lstbuffers[[i]]$radius <-dist[i] #add the radius
  32. }
  33.  
  34. buffers <- do.call(rbind,lstbuffers) #DOES NOT WORK, I get a matrix of lists :(
Add Comment
Please, Sign In to add comment