Esiste un modo per calcolare la densità della strada (km/km²) all'interno di un buffer attorno alle linee spaziali? Le strade sono rappresentate da pixel (1 pixel = 625 m²) in un raster. Così ho iniziato a convertire i pixel stradali in polilinee usando la funzione rasterToContour
(package raster)
. Quindi, sto pensando di calcolare la lunghezza totale delle linee all'interno del buffer (in km) e l'area del buffer (in km²).Calcola la densità di linea all'interno di un buffer da un raster
r <- raster(rast_path)
x <- rasterToContour(r)
Ecco un esempio riproducibile:
## To create raster:
library(raster)
library(rgeos)
r <- raster(ncols=90, nrows=50)
values(r) <- sample(1:10, ncell(r), replace=TRUE)
## Road raster
r[r[] < 10] <- 0
r[r[] >= 10] <- 1
plot(r)
## To create spatial lines
line1 <- rbind(c(-125,0), c(0,60))
line2 <- rbind(c(0,60), c(40,5))
line3 <- rbind(c(40,5), c(15,-45))
line1_sp <- spLines(line1)
line2_sp <- spLines(line2)
line3_sp <- spLines(line3)
## To create buffer around lines
line2_buff <- gBuffer(line2_sp, width=20)
plot(line2_sp,add=T)
plot(line2_buff,add=T)
domanda Duplicate: http://gis.stackexchange.com/questions/177869/calculate-line-density-within-a-buffer- in -r – RobertH