Learn R Programming

tmap (version 1.2)

poly_to_raster: Convert spatial polygons to a raster

Description

Convert spatial polygons to a raster. For each raster cell, the data of the corresponding polygon is copied.

Usage

poly_to_raster(shp, nrow = NA, ncol = NA, N = 250000, use.cover = FALSE,
  to.Raster = FALSE, ...)

Arguments

shp
nrow
number of raster rows. If NA, it is automatically determined by N and the aspect ratio of shp.
ncol
number of raster columns. If NA, it is automatically determined by N and the aspect ratio of shp.
N
preferred number of raster cells.
use.cover
logical; should the cover method be used? This method determines per raster cell which polygon has the highest cover fraction. This method is better, but very slow, since N times the number of polygons combinations are processed (using the getCover<
to.Raster
logical; should the output be a Raster object (TRUE), or a SpatialGridDataFrame (FAL
...
arguments passed on to rasterize

Value

See Also

points_to_raster

Examples

Run this code
data(NLD_muni)
	
	# choropleth of 65+ population percentages
	qtm(NLD_muni, fill="pop_65plus", format="NLD")
	
	# rasterized version
	NLD_rst <- poly_to_raster(NLD_muni)
	qtm(NLD_rst, raster="pop_65plus", format="NLD")

Run the code above in your browser using DataLab