Learn R Programming

fieldRS (version 0.2.3)

rankPlots: rankPlots

Description

helps fix spelling mistakes in the labels of a set of samples.

Usage

rankPlots(
  x,
  y,
  z,
  min.size = 1,
  priority = c("diversity", "richness", "patch_count", "pixel_frequency",
    "road_distance")
)

Arguments

x

Object of class RasterLayer, RasterStack or RasterBrick.

y

Object of class SpatialPolygons or SpatialPolygonsDataFrame.

z

Object of class SpatialLines or SpatialLinesDataFrame.

min.size

Numeric element.

priority

Character vector.

Value

A list.

Details

For each polygon in y, the function will determine the distance between its centroid and the nearest road provided through z, count the number of classes in x and the number of patches of connected pixels and report on the proportion of non NA values. The patch count can be restricted to those with a size greater min.size which specifies the minimum number of pixels per patch. Then, the function will use this data to rank the elements of y according to the order of the keywords in priority. The user can choose one or more of the following keywords:

  • diversity - Priority given to the highest Shannon, class diversity.

  • richness - Priority given to the highest class richness (number of classes in plot / total number of classes).

  • pixel_frequency - Priority given to the highest non-NA pixel count.

  • patch_count - Priority given to the highest patch count.

  • road_distance - Priority given to shortest distance.

The final output is a data.frame reporting on:
  • x - Polygon centroid x coordinate.

  • y - Polygon centroid y coordinate.

  • mape - Mean Absolute Percent Error.

  • diversity - Class diversity.

  • richness - Class richeness.

  • pixel.frequency - Number of non-NA pixels.

  • road.distance - Linear distance to the closest road.

  • ranking - Priority ranking

See Also

derivePlots ccLabel

Examples

Run this code
# NOT RUN {
{

require(raster)
require(RStoolbox)
require(ggplot2)

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

# read road information
data(roads)

# unsupervised classification with kmeans
uc <- unsuperClass(r, nSamples=5000, nClasses=5)$map

# derive potential sampling plots
pp <- derivePlots(uc, 1000)

# plot ranking
pp@data <- rankPlots(uc, pp, roads)

# plot output
gp <- fortify(pp, region="ranking")
ggplot(gp, aes(x=long, y=lat, group=group, fill=as.numeric(id))) + 
geom_polygon() + scale_fill_continuous(name="Ranking")

}
# }

Run the code above in your browser using DataLab