Last chance! 50% off unlimited learning
Sale ends in
+proj=longlat
) and in map units (typically meters) when it is projected.
Distances are calculated by summing local distances between cells, which are connected with their neighbours in 8 directions.gridDistance(x, origin, omit=NULL, filename="", ...)
writeRaster
distance
for 'as the crow flies' distance. Additional distance measures and options (directions, cost-distance) are available in the 'gdistance
' package.#world lonlat raster
r <- raster(ncol=10,nrow=10)
r[] <- 1
r[48] <- 2
r[66:68] <- 3
d <- gridDistance(r,origin=2,omit=3)
plot(d)
#UTM small area
projection(r) <- "+proj=utm +zone=15 +ellps=GRS80 +datum=NAD83 +units=m +no_defs"
d <- gridDistance(r,origin=2,omit=3)
plot(d)
Run the code above in your browser using DataLab