Description Usage Arguments Value Examples
View source: R/rescale_raster.R
This function rescales the values of a raster between 0 and 1 so that they sum to 1. These values can then be used as weights.
1 | rescale_raster(rstr)
|
rstr |
a RasterLayer object |
A RasterLayer object with values between 0 and 1 and summing to 1.
1 2 3 4 5 6 7 8 9 10 11 12 13 | library(raster)
library(worldpopVN)
provinces <- sptools::gadm("vietnam", "sp", 1, intlib = FALSE, save = TRUE)
ppp2010 <- worldpopVN::getpop(2010)
hanoi <- sptools::crop_on_poly(ppp2010, subset(provinces,
VARNAME_1 == "Ha Noi"))
# before rescaling:
sum(values(hanoi), na.rm = TRUE)
# after rescaling:
sum(values(rescale_raster(hanoi)), na.rm = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.