forked from carlos-alberto-silva/rGEDI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpolyStatsLevel2BVPM.Rd
78 lines (66 loc) · 2.54 KB
/
polyStatsLevel2BVPM.Rd
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/polyStatsLevel2BVPM.R
\name{polyStatsLevel2BVPM}
\alias{polyStatsLevel2BVPM}
\title{Compute descriptive statistics of GEDI Level2BVPM-derived Metrics}
\usage{
polyStatsLevel2BVPM(level2BVPM, func, id=NULL)
}
\arguments{
\item{level2BVPM}{A GEDI Level2BVPM object (output of \code{\link[rGEDI:getLevel2BVPM]{getLevel2BVPM}} function). A S4 object of class "data.table".}
\item{func}{the function to be applied for computing the defined statistics}
\item{id}{a vector contatining the polygon id for each GEDI observation. Defaut is NULL}
}
\value{
A S4 object of class \code{\link[data.table:data.table]{data.table-class}}
containting Statistics of GEDI level2BVPM defined metrics
}
\description{
Computes a Series of Statistics of GEDI-derived Canopy Cover and Vertical Profile metrics (Level2BVPM)
for all obsercation or only those defined within a giving polygon
}
\examples{
# specify the path to GEDI level2B data (zip file)
level2B_fp_zip <- system.file("extdata",
"GEDI02_B_2019108080338_O01964_T05337_02_001_01_sub.zip",
package="rGEDI")
# Unzipping GEDI level2A data
level2Bpath <- unzip(level2B_fp_zip,exdir = dirname(level2B_fp_zip))
# Reading GEDI level2B data (h5 file)
level2b<-readLevel2B(level2Bpath=level2Bpath)
# specify 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)
# Get GEDI Canopy Cover and Vertical Profile Metrics
level2BVPM<-getLevel2BVPM(level2b)
head(level2BVPM)
# clipping level2BVPM by geometry
level2BVPM_clip = clipLevel2BVPMGeometry(level2BVPM, 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 max of the Total Plant Area Index
pai_max<-polyStatsLevel2BVPM(level2BVPM_clip,func=max(pai), id=NULL)
pai_max
# Computing the max of the Total Plant Area Index stratified by polygon
pai_max_poly<-polyStatsLevel2BVPM(level2BVPM_clip,func=max(pai), id="poly_id")
head(pai_max_poly)
# Computing the serie of statistics of canopy cover stratified by polygon
cover_metrics<-polyStatsLevel2BVPM(level2BVPM_clip,func=mySetOfMetrics(cover),
id=level2BVPM_clip$id)
head(cover_metrics)
close(level2b)
}
\seealso{
https://lpdaac.usgs.gov/products/gedi02_bv001/
}