Learn R Programming

raptr (version 0.1.6)

rasterizeGDAL: Rasterize polygon data using GDAL

Description

This function converts a SpatialPolygonsDataFrame to a RasterLayer using GDAL. It is expected to be faster than rasterize for large datasets. However, it will be significantly slower for small datasets because the data will need to be written and read from disk.

Usage

rasterizeGDAL(x, y, field = NULL)

Arguments

y

raster with dimensions, extent, and resolution to be used as a template for new raster.

field

character column name with values to burn into the output raster. If not supplied, default behaviour is to burn polygon indices into the raster.

Value

RasterLayer object.

See Also

rasterize, is.gdalInstalled.

Examples

Run this code
# NOT RUN {
# load dat
data(cs_pus,cs_spp)

# rasterize spatial polygon data
x <- rasterizeGDAL(cs_pus[1:5,], cs_spp[[1]])

# plot data
par(mfrow = c(1,2))
plot(cs_pus[1:5,], main = "original data")
plot(x, main = "rasterized data")
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab