Skip to content

Commit 7f9beb1

Browse files
committed
usage examples [WIP]
1 parent 553f9c7 commit 7f9beb1

7 files changed

Lines changed: 151 additions & 6 deletions

README.Rmd

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pak::pak("ctoney/FIAstemmap")
4848

4949
The data frame `cw_coef` provides a curated set of linear regression coefficients for predicting crown width from stem diameter of tree species in the conterminous US. The crown width prediction method also addresses potential issues in cases of extrapolation beyond the range of the model fitting data. Details are given in the documentation for `calc_crwidth()`. Input is a data frame of tree records which must have columns `SPCD` (FIA integer species code), `STATUSCD` (FIA integer tree status code, `1` = live) and `DIA` (FIA tree diameter in inches), here using the `plantation` example tree list.
5050

51-
```{r example}
51+
```{r predict-crwidth}
5252
library(FIAstemmap)
5353
5454
# structure of the cw_coef dataset
@@ -60,11 +60,11 @@ tree_list <- within(plantation, CRWIDTH <- calc_crwidth(plantation))
6060
str(tree_list)
6161
```
6262

63-
### Exloratory analysis
63+
### Exploratory analysis
6464

6565
Plot-level visualization and other exploratory analyses require input data with stem locations provided in columns `AZIMUTH` (horizontal angle from subplot/microplot center to the stem location, in range `0:359`) and `DIST` (stem distance from subplot/microplot center).
6666

67-
```{r example}
67+
```{r plot-crowns}
6868
# display modeled tree crowns projected vertically on boundaries of the FIA
6969
# four-subplot cluster design
7070
plot_crowns(tree_list, main = "plantation plot")
@@ -79,7 +79,7 @@ plot_crowns(tree_list, subplot = 4, microplot = TRUE,
7979

8080
Helper functions are provided to facilitate analyzing FIA tree lists as Spatial Point Patterns using the **spatstat** library. `create_fia_ppp()` returns an object of class `"ppp"` representing the point pattern of an FIA tree list in the 2-D plane. This object can be used with functions of package **spatstat.explore** for additional plotting capabilty, computation of descriptive spatial statistics, and other exploratory data analysis.
8181

82-
```{r example}
82+
```{r spatstat-explore}
8383
# point pattern object for the plantation tree list
8484
X <- create_fia_ppp(plantation)
8585
summary(X)

README.md

Lines changed: 147 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# FIAstemmap <a href="https://ctoney.github.io/FIAstemmap/"><img src="man/figures/logo.png" align="right" height="138" alt="FIAstemmap website" /></a>
55

66
<!-- badges: start -->
7+
78
[![R-CMD-check](https://github.com/ctoney/FIAstemmap/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/ctoney/FIAstemmap/actions/workflows/R-CMD-check.yaml)
89
<!-- badges: end -->
910

@@ -34,6 +35,18 @@ measurements has supported several applications of FIA data, including:
3435
- assessment of tree canopy cover estimation methods [\[12,
3536
13\]](#references)
3637

38+
Note that analysis or computation based on tree spatial pattern within a
39+
plot require input data with coordinates of individual stems given as
40+
aziumuth and distance from the sample center point. FIA no longer
41+
provide `AZIMUTH` and `DIST` attributes in the publicly available FIADB
42+
`TREE` table. The FIADB User Guide states that these attributes are now
43+
available by request from [FIA Spatial Data
44+
Services](https://research.fs.usda.gov/programs/fia/sds)
45+
[\[14\]](#references). Tree data without stem locations can be used in
46+
**FIAstemmap** with reduced functionality which includes predicting
47+
individual tree crown width and computing several stand structure
48+
metrics.
49+
3750
## Installation
3851

3952
You can install the development version of **FIAstemmap** with:
@@ -45,13 +58,136 @@ pak::pak("ctoney/FIAstemmap")
4558

4659
## Examples
4760

48-
TODO…
61+
### Predict crown width
62+
63+
The data frame `cw_coef` provides a curated set of linear regression
64+
coefficients for predicting crown width from stem diameter of tree
65+
species in the conterminous US. The crown width prediction method also
66+
addresses potential issues in cases of extrapolation beyond the range of
67+
the model fitting data. Details are given in the documentation for
68+
`calc_crwidth()`. Input is a data frame of tree records which must have
69+
columns `SPCD` (FIA integer species code), `STATUSCD` (FIA integer tree
70+
status code, `1` = live) and `DIA` (FIA tree diameter in inches), here
71+
using the `plantation` example tree list.
4972

5073
``` r
5174
library(FIAstemmap)
52-
## basic example code
75+
76+
# structure of the cw_coef dataset
77+
str(cw_coef)
78+
#> 'data.frame': 430 obs. of 8 variables:
79+
#> $ symbol : chr "ABAM" "ABCO" "ABGR" "ABLAA" ...
80+
#> $ SPCD : num 11 15 17 18 19 20 21 22 41 62 ...
81+
#> $ common_name: chr "Pacific silver fir" "white fir" "grand fir" "corkbark fir" ...
82+
#> $ surrogate : chr NA NA NA NA ...
83+
#> $ b0 : num 7.3 4.49 5.75 6.07 3.96 6.67 6.67 6.32 2.36 -2.12 ...
84+
#> $ b1 : num 0.59 0.92 1.11 0.37 0.64 0.43 0.43 0.65 0.99 1.73 ...
85+
#> $ b2 : num 0 -0.01 -0.01 0 0 0 0 0 0 -0.02 ...
86+
#> $ reference : chr "Bechtold (2004)" "Bechtold (2004)" "Bechtold (2004)" "Bechtold (2004)" ...
87+
88+
# add a column of predicted crown width to the plantation tree list
89+
# `within()` is used to modify only a copy of the example dataset
90+
tree_list <- within(plantation, CRWIDTH <- calc_crwidth(plantation))
91+
str(tree_list)
92+
#> 'data.frame': 91 obs. of 13 variables:
93+
#> $ PLT_CN : chr "61265063010478" "61265063010478" "61265063010478" "61265063010478" ...
94+
#> $ SUBP : int 1 1 1 1 1 1 1 1 1 1 ...
95+
#> $ TREE : int 4 1 2 3 5 6 10 7 8 9 ...
96+
#> $ AZIMUTH : int 21 282 185 4 24 48 93 60 90 92 ...
97+
#> $ DIST : num 22.7 9.1 10.1 22 11.7 14.9 22.4 19.5 9.5 16.3 ...
98+
#> $ STATUSCD : int 1 1 1 1 1 1 1 1 1 1 ...
99+
#> $ SPCD : int 131 131 131 131 131 131 131 131 131 131 ...
100+
#> $ DIA : num 6.7 7.7 6.1 9.5 8.2 5.9 5.6 5.1 9.3 8.1 ...
101+
#> $ HT : int 41 45 42 50 46 44 41 42 48 48 ...
102+
#> $ ACTUALHT : int 41 45 42 50 46 44 41 42 48 48 ...
103+
#> $ CCLCD : int 3 3 3 3 3 3 3 3 3 3 ...
104+
#> $ TPA_UNADJ: num 6.02 6.02 6.02 6.02 6.02 ...
105+
#> $ CRWIDTH : num 11.8 13.2 11 15.7 13.9 10.7 10.3 9.6 15.4 13.7 ...
106+
```
107+
108+
### Exploratory analysis
109+
110+
Plot-level visualization and other exploratory analyses require input
111+
data with stem locations provided in columns `AZIMUTH` (horizontal angle
112+
from subplot/microplot center to the stem location, in range `0:359`)
113+
and `DIST` (stem distance from subplot/microplot center).
114+
115+
``` r
116+
# display modeled tree crowns projected vertically on boundaries of the FIA
117+
# four-subplot cluster design
118+
plot_crowns(tree_list, main = "plantation plot")
119+
```
120+
121+
<img src="man/figures/README-plot-crowns-1.png" alt="" width="100%" />
122+
123+
``` r
124+
125+
# individual subplot
126+
plot_crowns(tree_list, subplot = 4, main = "plantation subplot 4")
127+
```
128+
129+
<img src="man/figures/README-plot-crowns-2.png" alt="" width="100%" />
130+
131+
``` r
132+
133+
# or microplot
134+
plot_crowns(tree_list, subplot = 4, microplot = TRUE,
135+
main = "plantation microplot 4")
136+
```
137+
138+
<img src="man/figures/README-plot-crowns-3.png" alt="" width="100%" />
139+
140+
Helper functions are provided to facilitate analyzing FIA tree lists as
141+
Spatial Point Patterns using the **spatstat** library.
142+
`create_fia_ppp()` returns an object of class `"ppp"` representing the
143+
point pattern of an FIA tree list in the 2-D plane. This object can be
144+
used with functions of package **spatstat.explore** for additional
145+
plotting capabilty, computation of descriptive spatial statistics, and
146+
other exploratory data analysis.
147+
148+
``` r
149+
# point pattern object for the plantation tree list
150+
X <- create_fia_ppp(plantation)
151+
summary(X)
152+
#> Planar point pattern: 89 points
153+
#> Average intensity 0.01229542 points per square foot
154+
#>
155+
#> Coordinates are given to 16 decimal places
156+
#>
157+
#> Window: polygonal boundary
158+
#> 4 separate polygons (no holes)
159+
#> vertices area relative.area
160+
#> polygon 1 360 1809.62 0.25
161+
#> polygon 2 360 1809.62 0.25
162+
#> polygon 3 360 1809.62 0.25
163+
#> polygon 4 360 1809.62 0.25
164+
#> enclosing rectangle: [-127.921, 127.921] x [-84.001, 144.001] feet
165+
#> (255.8 x 228 feet)
166+
#> Window area = 7238.47 square feet
167+
#> Unit of length: 1 foot
168+
#> Fraction of frame area: 0.124
169+
170+
plot(X, pch = 16, main = "Loblolly pine plantation")
171+
```
172+
173+
<img src="man/figures/README-spatstat-explore-1.png" alt="" width="100%" />
174+
175+
``` r
176+
177+
# compute Ripley's K-function applying isotropic edge correction
178+
K <- spatstat.explore::Kest(X, rmax = 12, correction = "isotropic")
179+
180+
# plot estimated values of K(r) along with theoretical values for a completely
181+
# random (Poisson) point process, suggestng spatial regularity in this case
182+
plot(K, main = "Ripley's K for the plantation trees")
53183
```
54184

185+
<img src="man/figures/README-spatstat-explore-2.png" alt="" width="100%" />
186+
187+
### Compute stand structure metrics
188+
189+
### Data processing
190+
55191
## References
56192

57193
\[1\] Toney, Chris; Shaw, John D.; Nelson, Mark D. 2009. A stem-map
@@ -138,3 +274,12 @@ Shettles. 2021. Predicting canopy cover of diverse forest types from
138274
individual tree measurements. *Forest Ecology and Management*, Volume
139275
501, 119682, ISSN 0378-1127,
140276
<https://doi.org/10.1016/j.foreco.2021.119682>.
277+
278+
\[14\] Burrill, Elizabeth A.; DiTommaso, Andrea M.; Turner, Jeffery A.;
279+
Pugh, Scott A.; Christensen, Glenn; Kralicek, Karin M.; Perry, Carol J.;
280+
Lepine, Lucie C.; Walker, David M.; Conkling, Barbara L. 2024. The
281+
Forest Inventory and Analysis Database, FIADB user guides, volume:
282+
database description (version 9.4), nationwide forest inventory (NFI).
283+
U.S. Department of Agriculture, Forest Service. 1016 p. \[Online\].
284+
Available at:
285+
<https://research.fs.usda.gov/understory/forest-inventory-and-analysis-database-user-guide-nfi>.
21.4 KB
Loading
23.1 KB
Loading
22.4 KB
Loading
13.4 KB
Loading
26 KB
Loading

0 commit comments

Comments
 (0)