"SpatialPoints*"
, "SpatialLines*"
, or "SpatialPolygons*"
object to a raster map, and (optional) writes it to an external file (GDAL-supported formats; writes to SAGA GIS format by default).## S3 method for class 'SpatialPoints':
vect2rast(obj, fname = names(obj)[1], cell.size, bbox,
file.name, silent = FALSE, method = c("raster", "SAGA")[1],
FIELD = 0, MULTIPLE = 1, LINE_TYPE = 0, GRID_TYPE = 2, ...)
## S3 method for class 'SpatialLines':
vect2rast(obj, fname = names(obj)[1], cell.size, bbox,
file.name, silent = FALSE, method = c("raster", "SAGA")[1],
FIELD = 0, MULTIPLE = 1, LINE_TYPE = 1, GRID_TYPE = 2, ...)
## S3 method for class 'SpatialPolygons':
vect2rast(obj, fname = names(obj)[1], cell.size, bbox,
file.name, silent = FALSE, method = c("raster", "SAGA")[1],
FIELD = 0, MULTIPLE = 0, LINE_TYPE = 1, GRID_TYPE = 2, ...)
rsaga.get.usage("grid_gridding", 0)
)rsaga.get.usage("grid_gridding", 0)
)rsaga.get.usage("grid_gridding", 0)
)rsaga.get.usage("grid_gridding", 0)
)raster::rasterize
command"SpatialGridDataFrame"
.rasterize
function available in the raster package. The advantage of vect2rast
, however, is that it requires no input from the user's side i.e. it automatically determines the grid cell size and the bounding box based on the properties of the input data set. The grid cell size is estimated based on the density/size of features in the map (nndist
function in "SpatialPoints"
cell size is determined as half the mean distance between the nearest points; (b) in the case of "SpatialLines"
half cell size is determined as half the mean distance between the lines; (c) in the case of polygon data cell size is determined as half the median size (area) of polygons of interest. For more details see method="SAGA"
.vect2rast.SpatialPoints
, raster::rasterize
, spatstat::nndist
data(eberg)
library(sp)
library(maptools)
library(spatstat)
coordinates(eberg) <- ~X+Y
data(eberg_zones)
# point map:
x <- vect2rast(eberg, fname = "SNDMHT_A")
image(x)
# polygon map:
x <- vect2rast(eberg_zones)
image(x)
# for large data sets use SAGA GIS:
x <- vect2rast(eberg_zones, method = "SAGA")
Run the code above in your browser using DataLab