split_on_poly: Splits a raster on a spatial polygon

Description Usage Arguments Value Examples

View source: R/split_on_poly.R

Description

This function combines the above functions as_list and crop_on_poly. to split a RasterLayer object on the features of a SpatialPpolygons* object. Of course, the RasterLayer and the SpatialPpolygons* objects need to superpose.

Usage

1
split_on_poly(rstr, plgns)

Arguments

rstr

A RasterLayer

plgns

A SpatialPolygon* object

Value

A list of RasterLayer objects.

Examples

1
2
3
4
5
6
7
8
9
library(worldpopVN)

provinces <- sptools::gadm("vietnam", "sp", 1, intlib = FALSE, save = TRUE)
ppp2010 <- worldpopVN::getpop(2010)
class(ppp2010)

ppp2010_split <- split_on_poly(ppp2010, provinces[1:3, ])
class(ppp2010_split)
table(sapply(ppp2010_split, class))

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