Unlimited learning, half price | 50% off

Last chance! 50% off unlimited learning

Sale ends in


CAWaR (version 0.0.2)

splitSamples: splitSamples

Description

Aggregates a spatial object into regions.

Usage

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.

Value

A list.

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:

  • region.id - Class dependent region label for each element in x.

  • region.frequency - Pixel count for each unique value in region.id.

See Also

phenoCropVal phenoCropClass

Examples

Run this code
# NOT RUN {
{

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)

}
# }

Run the code above in your browser using DataLab