+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(object, originValue, omitValue, filename, ...)
overwrite
Logical. If TRUE
, "filename" will be overwritten if it exists
format
Character. Output file type. See writeRaster
datatype
Character. Output data type. See dataType
progress
Character. Valid values are "text", "tcltk", "windows" (on that platform only) and ""
}#world lonlat raster
r <- raster(ncol=10,nrow=10)
r[] <- 1
r[48] <- 2
r[66:68] <- 3
distRaster <- gridDistance(r,originValue=2,omitValue=3)
plot(distRaster)
#UTM small area
projection(r) <- "+proj=utm +zone=15 +ellps=GRS80 +datum=NAD83 +units=m +no_defs"
distRaster <- gridDistance(r,originValue=2,omitValue=3)
plot(distRaster)
Run the code above in your browser using DataLab