splitSamples: splitSamples

Description Usage Arguments Details Value See Also Examples

View source: R/splitSamples.R

Description

Aggregates a spatial object into regions.

Usage

1
splitSamples(x, y, z, agg.radius = agg.radius)

Arguments

x

A SpatialPoints or a SpatialPolygons object.

y

A RasterLayer.

z

A vector.

agg.radius

Numeric element.

Details

For each class in z, the function converts the elements in x into a raster layer using y as a basis. Then, it aggregates all pixels that are within a given distance of each other - defined by agg.radius using ccLabel. The output is a list consisting of:

Value

A list.

See Also

phenoCropVal phenoCropClass

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
{

require(raster)
require(fieldRS)

# read raster data
r <- brick(system.file("extdata", "ndvi.tif", package="fieldRS"))

# read field data
data(fieldData)
fieldData <- fieldData[3:4,]

# find polygon clusters
k <- splitSamples(fieldData, r, fieldData$crop, agg.radius=30)
fieldData$ID <- as.factor(k$region.id)

# plot regions with labels
spplot(fieldData["ID"])

# show pixel count per region
head(k$region.frequency)

}

CAWaR documentation built on July 8, 2020, 7:06 p.m.