rescale_raster: Rescales the values of a raster as weights

Description Usage Arguments Value Examples

View source: R/rescale_raster.R

Description

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.

Usage

1

Arguments

rstr

a RasterLayer object

Value

A RasterLayer object with values between 0 and 1 and summing to 1.

Examples

 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)

choisy/sptools documentation built on Aug. 22, 2019, 12:57 p.m.