lidar_clip_and_stats: Clip by polygons and calculate stats from raw raster tables...

View source: R/lfcLiDAR.R

lidar_clip_and_statsR Documentation

Clip by polygons and calculate stats from raw raster tables (20x20m)

Description

lidar_clip_and_stats is a wrapper for the $clip_and_stats method of lfcLiDAR objects. See lidar.

Usage

lidar_clip_and_stats(object, sf, polygon_id_variable, variables)

Arguments

object

lfcLiDAR object, as created by lidar

sf

sf object with the polygon/s to clip

polygon_id_variable

character vector of length 1 with the name of the variable of sf that contains the polygon identificator (name, code...)

variables

character vector with the names of the variables to access

Details

The stats returned are the following:

  • poly_km2: Area in square kilometers of the polygon supplied

  • pixels: Pixel count intersecting with the polygon supplied. Only pixels with value are counted

  • average: Average value for the pixels intersecting with the polygon supplied

  • min: Minimum value for the pixels intersecting with the polygon supplied

  • max: Maximum value for the pixels intersecting with the polygon supplied

  • sd: Standard deviation value for the pixels intersecting with the polygon supplied

  • km2: Area covered by the raster intersecting with the polygon supplied

  • km2_perc: Percentage of the supplied polygon area covered by the raster

Value

This function returns the same sf object provided with new columns with the mean of each polygon for each variable requested.

See Also

Other LiDAR functions: lidar_avail_tables(), lidar_describe_var(), lidar_get_data(), lidar_get_lowres_raster(), lidar_point_value(), lidar()

Examples

if (interactive()) {
library(dplyr)
lidardb <- lidar()

polygons_data <- lidar_get_data('lidar_provincias', 'DBH') |>
  select(poly_id, DBH_check = DBH_mean, geometry)

dbh_provinces <- lidar_clip_and_stats(lidardb, polygons_data, 'poly_id', 'DBH')
dbh_provinces$DBH_check == dbh_provinces$DBH_mean

# lidardb is an R6 object, so the previous example is the same as:
lidardb$clip_and_stats(polygons_data, 'poly_id', 'DBH')
}


MalditoBarbudo/lfcdata documentation built on May 2, 2023, 10:30 p.m.