sample_raster: Generate random sample polygons from a raster layer,...

Description Usage Arguments Value Examples

Description

Useful for gathering training data for an image classification. With the default settings, the output polygons will be perfectly aligned with the pixels in the input raster.

Usage

1
2
sample_raster(x, size, strata = NULL, side = xres(x), fields = c(),
  na.rm = TRUE, exp = 5)

Arguments

x

a Raster*

size

the sample size (number of sample polygons to return)

strata

(optional) a RasterLayer of integers giving the strata of each pixel (for example, a classified image)

side

desired length for each side of the sample polygon (units of the input Raster*, usually meters)

fields

a list of fields to include in the output SpatialPolygonsDataFrame (such as a "class" field if you will be digitizing classes).

na.rm

whether to remove pixels with NA values from the sample

exp

multiplier used to draw larger initial sample to account for the loss of sample polygons lost because they contain NAs, and, for stratified sampling, to account for classes that occur very infrequently in the data. Increase this value if the final sample has fewer sample polygons than desired.

Value

a SpatialPolygonsDataFrame

Examples

1
2
3
4
5
6
7
8
9
## Not run: 
set.seed(0)
L5TSR_1986_b1 <- raster(L5TSR_1986, layer=1)
training_polys <- sample_raster(L5TSR_1986_b1, 30,
                                  side=6*xres(L5TSR_1986_b1))
plot(L5TSR_1986_b1)
plot(training_polys, add=TRUE)

## End(Not run)

azvoleff/teamlucc documentation built on May 11, 2019, 5:19 p.m.