polyStatsLevel2AM: Compute descriptive statistics of GEDI Elevation and Height...

Description Usage Arguments Value See Also Examples

View source: R/polyStatsLevel2AM.R

Description

Computes a Series of Statistics from GEDI derived Elevation and Height Metrics (Level2A) within a given area defined or not by a polygon

Usage

1
polyStatsLevel2AM(level2AM, func, id=NULL)

Arguments

level2AM

A GEDI Level2AM object (output of getLevel2AM function). An S4 object of class "data.table".

func

The function to be applied for computing the defined statistics

id

A vector containing the polygon id for each GEDI observation. Default is NULL

Value

Returns an S4 object of class data.table-class containting Statistics of GEDI level2A defined metrics

See Also

https://lpdaac.usgs.gov/products/gedi02_av001/

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# Specifying the path to GEDI level2A data (zip file)
outdir = tempdir()
level2A_fp_zip <- system.file("extdata",
                  "GEDI02_A_2019108080338_O01964_T05337_02_001_01_sub.zip",
                  package="rGEDI")

# Unzipping GEDI level2A data
level2Apath <- unzip(level2A_fp_zip,exdir = outdir)

# Reading GEDI level2A data (h5 file)
level2a<-readLevel2A(level2Apath=level2Apath)

# Specifying the path to shapefile
polygon_filepath <- system.file("extdata", "stands_cerrado.shp", package="rGEDI")

# Reading shapefile as SpatialPolygonsDataFrame object
library(raster)
polygon_spdf<-shapefile(polygon_filepath)

# Extracting GEDI Eleveation and Relative Metrics (level2A)
level2AM<-getLevel2AM(level2a)
head(level2AM)

# Clipping GEDI data by geometry
level2AM_clip = clipLevel2AMGeometry(level2AM, polygon_spdf, split_by="id")

#' Define your own function
mySetOfMetrics = function(x)
{
metrics = list(
   min =min(x), # Min of x
   max = max(x), # Max of x
   mean = mean(x), # Mean of x
   sd = sd(x)# Sd of x
 )
 return(metrics)
}

# Computing the maximum of RH100
RH100max<-polyStatsLevel2AM(level2AM_clip,func=max(rh100), id=NULL)

# Computing the maximum of RH100 stratified by polygon
RH100max_poly<-polyStatsLevel2AM(level2AM_clip,func=max(rh100), id=NULL)

# Computing a serie statistics for GEDI metrics stratified by polygon
RH100metrics<-polyStatsLevel2AM(level2AM_clip,func=mySetOfMetrics(rh100),
                     id=level2AM_clip$id)

close(level2a)

rGEDI documentation built on Jan. 19, 2021, 3:01 p.m.