vect2rast {plotKML}R Documentation

Convert points, lines and/or polygons to rasters

Description

Converts any "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).

Usage

## S4 method for signature '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, ... )
## S4 method for signature '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, ... )
## S4 method for signature '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, ... )

Arguments

obj

Spatial-PointsDataFrame,-LinesDataFrame or -PolygonsDataFrame object

fname

character; target variable

cell.size

numeric; output cell size

bbox

matrix; output bounding box

file.name

character; (optional) output file name

silent

logical; specifies whether to print the output

method

character; output rasterization engine (either raster package or SAGA GIS)

FIELD

integer; target column in the output shape file (see rsaga.get.usage("grid_gridding", 0))

MULTIPLE

integer; method for multiple values (see rsaga.get.usage("grid_gridding", 0))

LINE_TYPE

integer; method for lines (see rsaga.get.usage("grid_gridding", 0))

GRID_TYPE

integer; preferred target grid type (see rsaga.get.usage("grid_gridding", 0))

...

additional arguments that can be passed to the raster::rasterize command

Details

This function basically extends the 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 spatstat package): (a) in the case of "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 Hengl (2006). To process larger vector maps consider using method="SAGA".

Value

Returns an object of type "SpatialGridDataFrame".

Author(s)

Tomislav Hengl

References

See Also

vect2rast.SpatialPoints, raster::rasterize, spatstat::nndist

Examples

## Not run: 
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")

## End(Not run)

[Package plotKML version 0.5-9 Index]