Description Usage Arguments Details Value See Also Examples
Aggregates a spatial object into regions.
| 1 | splitSamples(x, y, z, agg.radius = agg.radius)
 | 
| x | A SpatialPoints or a SpatialPolygons object. | 
| y | A RasterLayer. | 
| z | A vector. | 
| agg.radius | Numeric element. | 
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.
A list.
| 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)
}
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.