View source: R/utils_shapefile.R
shapefile_build | R Documentation |
This function takes a mosaic raster to create a shapefile containing polygons
for the specified regions. Users can drawn Areas of Interest (AOIs) that can
be either a polygon with n sides, or a grid, defined by nrow
, and ncol
arguments.
shapefile_build(
mosaic,
basemap = NULL,
controlpoints = NULL,
r = 3,
g = 2,
b = 1,
crop_to_shape_ext = TRUE,
grid = TRUE,
nrow = 1,
ncol = 1,
plot_width = NULL,
plot_height = NULL,
layout = "lrtb",
serpentine = TRUE,
build_shapefile = TRUE,
check_shapefile = FALSE,
sf_to_polygon = FALSE,
buffer_edge = 1,
buffer_col = 0,
buffer_row = 0,
as_sf = TRUE,
verbose = TRUE,
max_pixels = 1e+06,
downsample = NULL,
quantiles = c(0, 1)
)
mosaic |
A mosaic of class |
basemap |
An optional |
controlpoints |
An |
r , g , b |
The layer for the Red, Green and Blue band, respectively.
Defaults to |
crop_to_shape_ext |
Crop the mosaic to the extension of shapefile?
Defaults to |
grid |
Logical, indicating whether to use a grid for segmentation (default: TRUE). |
nrow |
Number of rows for the grid (default: 1). |
ncol |
Number of columns for the grid (default: 1). |
plot_width , plot_height |
The width and height of the plot shape (in the
mosaic unit). It is mutually exclusiv with |
layout |
Character: one of
|
serpentine |
Create a serpentine-based layout? Defaults to |
build_shapefile |
Logical, indicating whether to interactively draw ROIs
if the shapefile is |
check_shapefile |
Logical, indicating whether to validate the shapefile with an interactive map view (default: TRUE). This enables live editing of the drawn shapefile by deleting or changing the drawn grids. |
sf_to_polygon |
Convert sf geometry like POINTS and LINES to POLYGONS?
Defaults to |
buffer_edge |
Width of the buffer around the shapefile (default: 5). |
buffer_col , buffer_row |
Buffering factor for the columns and rows, respectively, of each individual plot's side. A value between 0 and 0.5 where 0 means no buffering and 0.5 means complete buffering (default: 0). A value of 0.25 will buffer the plot by 25% on each side. |
as_sf |
Logical value indicating whether to convert the imported
shapefile to an |
verbose |
Logical, indicating whether to display verbose output (default: TRUE). |
max_pixels |
Maximum number of pixels to render in the map or plot (default: 500000). |
downsample |
Downsampling factor to reduce the number of pixels
(default: NULL). In this case, if the number of pixels in the image (width
x height) is greater than |
quantiles |
the upper and lower quantiles used for color stretching. |
Since multiple blocks can be created, the length of arguments grid
, nrow
,
ncol
, buffer_edge
, buffer_col
, and buffer_row
can be either an scalar
(the same argument applied to all the drawn blocks), or a vector with the
same length as the number of drawn blocks. In the last, shapefiles in each
block can be created with different dimensions.
A list with the built shapefile. Each element is an sf
object with
the coordinates of the drawn polygons.
if(interactive()){
library(pliman)
mosaic <- mosaic_input(system.file("ex/elev.tif", package="terra"))
shps <-
shapefile_build(mosaic,
nrow = 6,
ncol = 3,
buffer_row = -0.05,
buffer_col = -0.25,
check_shapefile = FALSE,
build_shapefile = FALSE) ## Use TRUE to interactively build the plots
mosaic_plot(mosaic)
shapefile_plot(shps[[1]], add = TRUE)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.