rasterize_vector: Rasterize spatial vector dataset

View source: R/rasterize_vector.R

rasterize_vectorR Documentation

Rasterize spatial vector dataset

Description

Converts vector object to a raster with specified extent and resolution.

Usage

rasterize_vector(
  vector_data,
  outfile,
  template_raster,
  extent,
  res,
  crs,
  field,
  burn_value,
  datatype = "Float32",
  overwrite = FALSE,
  return_rast = FALSE
)

Arguments

vector_data

Character. File path to vector spatial data.

outfile

Raster output file path. Parent directory will be created recursively if required.

template_raster

Optional. Raster* object or a file path to template raster. If this is provided, extent, res, and crs will be taken from this raster unless they are also passed to this function. If x is not provided, then extent and res must be provided.

extent

Either a character path to a raster file, an Extent object (or an object from which such an extent can be extracted), or a numeric vector with four elements giving xmin, xmax, ymin, ymax.

res

Numeric or integer vector giving the horizontal and vertical spatial resolution of the target raster, in units of crs. If a single value is given, it will be used for both horizontal and vertical resolution.

crs

Target coordinate reference system as a PROJ string (character) an object of class CRS. If missing and template_raster is supplied, the crs of template_raster will be used. If template_raster is also not supplied, the CRS of vector_data will be used.

field

Character. Name of attribute to be burned into raster.

burn_value

Numeric. A constant value to burn into raster.

datatype

Character. Output data type (see [gdal_rasterize(https://gdal.org/programs/gdal_rasterize.html) documentation).

overwrite

Logical. Should outfile be overwritten if it exists?

return_rast

Logical. Return object to R?

Value

A binarized raster is written to outfile, and returned to R as a RasterLayer if return_rast is TRUE.


jscamac/edmaps documentation built on June 11, 2022, 1:26 a.m.