Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Polygon
- x <- structure(list(AREA = 1489841.35074, geometry = structure(list(
- structure(list(structure(c(4371395.39166986, 4371395.39166986,
- 4372634.07252284, 4372634.07252284, 4371395.39166986, 5478810.68590502,
- 5480013.45040013, 5480013.45040013, 5478810.68590502, 5478810.68590502
- ), .Dim = c(5L, 2L))), class = c("XY", "POLYGON", "sfg"))), n_empty = 0L, crs = structure(list(
- 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",
- "proj4string"), class = "crs"), class = c("sfc_POLYGON", "sfc"
- ), precision = 0, bbox = structure(c(4371395.39166986, 5478810.68590502,
- 4372634.07252284, 5480013.45040013), .Names = c("xmin", "ymin",
- "xmax", "ymax"), class = "bbox"))), .Names = c("AREA", "geometry"
- ), row.names = c(NA, -1L), class = c("sf", "data.frame"), sf_column = "geometry", agr = structure(NA_integer_, class = "factor", .Label = c("constant",
- "aggregate", "identity"), .Names = "AREA"))
- library(sf)
- #distances for buffers "aggregate", "identity"), .Names = "AREA")) "aggregate", "identity"), .Names = "AREA")
- dist <- c(50,500,1000,3000)
- #list holding the buffer rings
- lstbuffers <-list()
- for (i in seq(dist)){
- #first buffer
- if (i == 1){
- lstbuffers[[i]]<- st_buffer(x,dist[i])
- }else{
- #next buffers as rings around the previous
- lstbuffers[[i]] <- st_difference(st_buffer(x,dist[i]),st_buffer(x, dist[i-1]))
- }
- lstbuffers[[i]]$radius <-dist[i] #add the radius
- }
- buffers <- do.call(rbind,lstbuffers) #DOES NOT WORK, I get a matrix of lists :(
Add Comment
Please, Sign In to add comment