Description Usage Arguments Details Value See Also Examples
Bin spatial points to a raster. For each raster cell, the number of points are counted. Optionally, a factor variable can be specified by which the points are counts are split. Note that this function supports sf
objects, but still uses sp-based methods (see details).
1 2 |
shp |
shape object. a |
nrow |
number of raster rows. If |
ncol |
number of raster columns. If |
N |
preferred number of raster cells. |
by |
name of a data variable which should be a factor. The points are split and counted according to the levels of this factor. |
to.Raster |
not used anymore, since the output is always a |
This function is a wrapper around rasterize
.
This function supports sf
objects, but still uses sp-based methods, from the packages sp, rgeos, and/or rgdal.
a RasterBrick
is returned when by
is specified, and a RasterLayer
when by
is unspecified.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ## Not run:
if (require(tmap)) {
data(NLD_muni, NLD_prov)
# sample points (each point represents 1000 people)
NLD_muni_points <- sample_dots(NLD_muni, vars = "population",
w=1000, convert2density = TRUE)
# dot map
tm_shape(NLD_muni_points) + tm_dots()
# convert points to raster
NLD_rst <- points_to_raster(NLD_muni_points, N = 1e4)
# plot raster
tm_shape(NLD_rst) +
tm_raster() +
tm_shape(NLD_prov) +
tm_borders() +
tm_format("NLD") + tm_style("grey")
}
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.