plot_index_shp {pliman} | R Documentation |
Plot rectangles colored by a quantitative attribute and overlay on an RGB image
Description
This function plots rectangles on top of an RGB image, where each rectangle
is colored based on a quantitative variable. The quantitative variable is
specified in the attribute
argument and should be present in the
object_index
of the object
computed using analyze_objects_shp()
. The
rectangles are colored using a color scale.
Usage
plot_index_shp(
object,
attribute = "coverage",
color = c("red", "green"),
viewer = c("mapview", "base"),
max_pixels = 5e+05,
downsample = NULL,
downsample_fun = NULL,
alpha = 0.5,
legend.position = "bottom",
na.color = "gray",
classes = 6,
round = 3,
horiz = TRUE
)
Arguments
object |
An object computed with |
attribute |
The name of the quantitative variable in the
|
color |
A vector of two colors to be used for the color scale. |
viewer |
The viewer option. If not provided, the value is retrieved
using |
max_pixels |
integer > 0. Maximum number of cells to plot the index. If
|
downsample |
integer; for each dimension the number of
pixels/lines/bands etc that will be skipped; Defaults to |
downsample_fun |
function; if given, downsampling will apply
|
alpha |
The transparency level of the rectangles' color (between 0 and 1). |
legend.position |
The position of the color legend, either
|
na.color |
The color to be used for rectangles with missing values in the quantitative variable. |
classes |
The number of classes in the color scale. |
round |
The number of decimal places to round the legend values. |
horiz |
Logical, whether the legend should be horizontal ( |
Value
The function plots rectangles colored by the specified quantitative variable on top of the RGB image and shows the continuous color legend outside the plot.
Examples
if(interactive()){
library(pliman)
# Computes the DGCI index for each flax leaf
flax <- image_pliman("flax_leaves.jpg", plot =TRUE)
res <-
analyze_objects_shp(flax,
buffer_x = 0.2,
buffer_y = 0.2,
nrow = 3,
ncol = 5,
plot = FALSE,
object_index = "DGCI")
plot(res$final_image)
plot_index_shp(res)
}