Skip to content

Commit c900f4a

Browse files
committed
include western_redcedar in the readme examples
1 parent 7e6e64c commit c900f4a

6 files changed

Lines changed: 100 additions & 49 deletions

File tree

README.Rmd

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ The data frame `cw_coef` contains a curated set of linear regression coefficient
5252
```{r predict-crwidth}
5353
library(FIAstemmap)
5454
55-
# regression coefficients for estimating crown width from diameter are included
56-
# see `?cw_coef`
55+
# Regression coefficients for estimating crown width from diameter are included.
56+
# See `?cw_coef`.
5757
head(cw_coef)
5858
59-
# add a column of predicted crown widths to the `plantation` tree list
60-
# `within()` modifies a copy of the example dataset
59+
# Add a column of predicted crown widths to the `plantation` tree list.
60+
# `within()` modifies a copy of the example dataset.
6161
tree_list <- within(plantation, CRWIDTH <- calc_crwidth(plantation))
6262
str(tree_list)
6363
```
@@ -67,7 +67,7 @@ str(tree_list)
6767
Plot-level visualization and other exploratory analyses require input data with individual stem locations given in columns named `AZIMUTH` (horizontal angle from subplot/microplot center, `0:359`) and `DIST` (distance from subplot/microplot center).
6868

6969
```{r plot-crowns}
70-
# display modeled tree crowns projected vertically on the FIA plot boundary
70+
# Display modeled tree crowns projected vertically on the FIA plot boundary.
7171
plot_crowns(tree_list, main = "Loblolly pine plantation")
7272
7373
# individual subplot
@@ -82,55 +82,67 @@ plot_crowns(tree_list, subplot = 4, microplot = TRUE,
8282
Helper functions facilitate the analysis of 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 **spatstat.explore** which provide additional plotting capabilities, computation of descriptive spatial statistics, and other exploratory data analysis.
8383

8484
```{r spatstat-explore}
85-
# create a spatstat point pattern object for the plantation tree list
85+
## Create a spatstat point pattern object for the pine plantation tree list.
8686
X <- create_fia_ppp(plantation)
8787
summary(X)
8888
89-
plot(X, pch = 16, background = "#fdf6e3", main = "plantation point pattern")
89+
plot(X, pch = 16, background = "#fdf6e3",
90+
main = "Pine plantation point pattern")
9091
91-
# compute Ripley's K-function applying isotropic edge correction
92+
# Compute Ripley's K-function applying isotropic edge correction.
9293
K <- spatstat.explore::Kest(X, rmax = 12, correction = "isotropic")
9394
94-
# plot estimated K(r) along with theoretical values for a random point process,
95-
# suggesting spatial regularity in this case
96-
plot(K, main = "Ripley's K for the plantation trees")
95+
# Plot estimated K(r) along with theoretical values for a random point process,
96+
# suggesting spatial regularity in this case.
97+
plot(K, main = "Ripley's K for the plantation FIA plot")
98+
99+
## Spatial point pattern for the western redcedar tree list.
100+
X <- create_fia_ppp(western_redcedar)
101+
summary(X)
102+
103+
plot(X, pch = 16, background = "#fdf6e3",
104+
main = "Western redcedar point pattern")
105+
106+
K <- spatstat.explore::Kest(X, rmax = 12, correction = "isotropic")
107+
108+
plot(K, main = "Ripley's K for the western redcedar FIA plot")
97109
```
98110

99111
### Compute stand structure metrics
100112

101113
```{r stand-structure}
102-
## compute fractional tree canopy cover of a specific sampled area by overlaying
103-
## modeled crowns
114+
## Compute fractional tree canopy cover of a specific sampled area by overlaying
115+
## modeled crowns.
104116
105-
# subplot 1 of the plantation plot (subplot radius 24 ft)
106-
# omit saplings which are only sampled in the microplot
117+
# Subplot 1 of the plantation plot (subplot radius 24 ft).
118+
# Omit saplings which are only sampled in the microplot.
107119
# visualized with: `plot_crowns(tree_list, subplot = 1)`
108120
tree_list[tree_list$SUBP == 1 & tree_list$DIA >= 5, ] |>
109121
calc_crown_overlay(sample_radius = 24)
110122
111-
## calculate stand height metrics, which are also included by default in the
112-
## output of `calc_tcc_metrics()` (see below)
123+
## Calculate stand height metrics, which are also included by default in the
124+
## output of `calc_tcc_metrics()` (see below).
113125
114126
# compute stand height metrics only
115127
# calc_ht_metrics(plantation)
116128
117-
## predict plot-level canopy cover from individual tree measurements
129+
## Predict plot-level canopy cover from individual tree measurements.
118130
119-
# by default, TCC is predicted using the "stem-map" model, full output returned
131+
# By default, TCC is predicted using the "stem-map" model, full output returned.
120132
calc_tcc_metrics(plantation)
121133
122-
# return only the predicted TCC value (`$model_tcc`)
134+
# Return only the predicted TCC value (`$model_tcc`).
123135
calc_tcc_metrics(plantation, full_output = FALSE)
124136
125-
# using the "FVS method", which assumes that trees are randomly located
137+
# Using the "FVS method", which assumes that trees are randomly located.
126138
calc_tcc_metrics(plantation, stem_map = FALSE, full_output = FALSE)
127139
```
128140

129141
### Data processing
130142

131143
```{r data-proc}
132-
# load tree data from a file or database connection
133-
# Lolo NF, single-condition forest plots, INVYR 2022, from public FIADB
144+
# Load tree data from a file or database connection.
145+
# Lolo NF, single-condition forested plots, INVYR = 2022, from public FIADB
134146
f <- system.file("extdata/mt_lnf_2022_1cond_tree.csv", package="FIAstemmap")
135147
tree_table <- load_tree_data(f)
136148

README.md

Lines changed: 65 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ dataset used here is an example tree list included in the package.
7474
``` r
7575
library(FIAstemmap)
7676

77-
# regression coefficients for estimating crown width from diameter are included
78-
# see `?cw_coef`
77+
# Regression coefficients for estimating crown width from diameter are included.
78+
# See `?cw_coef`.
7979
head(cw_coef)
8080
#> symbol SPCD common_name surrogate b0 b1 b2 reference
8181
#> 1 ABAM 11 Pacific silver fir <NA> 7.30 0.59 0.00 Bechtold (2004)
@@ -85,8 +85,8 @@ head(cw_coef)
8585
#> 5 ABLA 19 subalpine fir <NA> 3.96 0.64 0.00 Bechtold (2004)
8686
#> 6 ABMA 20 California red fir <NA> 6.67 0.43 0.00 Gill et al. (2000)
8787

88-
# add a column of predicted crown widths to the `plantation` tree list
89-
# `within()` modifies a copy of the example dataset
88+
# Add a column of predicted crown widths to the `plantation` tree list.
89+
# `within()` modifies a copy of the example dataset.
9090
tree_list <- within(plantation, CRWIDTH <- calc_crwidth(plantation))
9191
str(tree_list)
9292
#> 'data.frame': 91 obs. of 13 variables:
@@ -113,7 +113,7 @@ data with individual stem locations given in columns named `AZIMUTH`
113113
(distance from subplot/microplot center).
114114

115115
``` r
116-
# display modeled tree crowns projected vertically on the FIA plot boundary
116+
# Display modeled tree crowns projected vertically on the FIA plot boundary.
117117
plot_crowns(tree_list, main = "Loblolly pine plantation")
118118
```
119119

@@ -146,7 +146,7 @@ computation of descriptive spatial statistics, and other exploratory
146146
data analysis.
147147

148148
``` r
149-
# create a spatstat point pattern object for the plantation tree list
149+
## Create a spatstat point pattern object for the pine plantation tree list.
150150
X <- create_fia_ppp(plantation)
151151
summary(X)
152152
#> Planar point pattern: 89 points
@@ -167,45 +167,84 @@ summary(X)
167167
#> Unit of length: 1 foot
168168
#> Fraction of frame area: 0.124
169169

170-
plot(X, pch = 16, background = "#fdf6e3", main = "plantation point pattern")
170+
plot(X, pch = 16, background = "#fdf6e3",
171+
main = "Pine plantation point pattern")
171172
```
172173

173174
<img src="man/figures/README-spatstat-explore-1.png" alt="" width="70%" />
174175

175176
``` r
176177

177-
# compute Ripley's K-function applying isotropic edge correction
178+
# Compute Ripley's K-function applying isotropic edge correction.
178179
K <- spatstat.explore::Kest(X, rmax = 12, correction = "isotropic")
179180

180-
# plot estimated K(r) along with theoretical values for a random point process,
181-
# suggesting spatial regularity in this case
182-
plot(K, main = "Ripley's K for the plantation trees")
181+
# Plot estimated K(r) along with theoretical values for a random point process,
182+
# suggesting spatial regularity in this case.
183+
plot(K, main = "Ripley's K for the plantation FIA plot")
183184
```
184185

185186
<img src="man/figures/README-spatstat-explore-2.png" alt="" width="70%" />
186187

188+
``` r
189+
190+
## Spatial point pattern for the western redcedar tree list.
191+
X <- create_fia_ppp(western_redcedar)
192+
summary(X)
193+
#> Planar point pattern: 24 points
194+
#> Average intensity 0.00331562 points per square foot
195+
#>
196+
#> Coordinates are given to 15 decimal places
197+
#>
198+
#> Window: polygonal boundary
199+
#> 4 separate polygons (no holes)
200+
#> vertices area relative.area
201+
#> polygon 1 360 1809.62 0.25
202+
#> polygon 2 360 1809.62 0.25
203+
#> polygon 3 360 1809.62 0.25
204+
#> polygon 4 360 1809.62 0.25
205+
#> enclosing rectangle: [-127.921, 127.921] x [-84.001, 144.001] feet
206+
#> (255.8 x 228 feet)
207+
#> Window area = 7238.47 square feet
208+
#> Unit of length: 1 foot
209+
#> Fraction of frame area: 0.124
210+
211+
plot(X, pch = 16, background = "#fdf6e3",
212+
main = "Western redcedar point pattern")
213+
```
214+
215+
<img src="man/figures/README-spatstat-explore-3.png" alt="" width="70%" />
216+
217+
``` r
218+
219+
K <- spatstat.explore::Kest(X, rmax = 12, correction = "isotropic")
220+
221+
plot(K, main = "Ripley's K for the western redcedar FIA plot")
222+
```
223+
224+
<img src="man/figures/README-spatstat-explore-4.png" alt="" width="70%" />
225+
187226
### Compute stand structure metrics
188227

189228
``` r
190-
## compute fractional tree canopy cover of a specific sampled area by overlaying
191-
## modeled crowns
229+
## Compute fractional tree canopy cover of a specific sampled area by overlaying
230+
## modeled crowns.
192231

193-
# subplot 1 of the plantation plot (subplot radius 24 ft)
194-
# omit saplings which are only sampled in the microplot
232+
# Subplot 1 of the plantation plot (subplot radius 24 ft).
233+
# Omit saplings which are only sampled in the microplot.
195234
# visualized with: `plot_crowns(tree_list, subplot = 1)`
196235
tree_list[tree_list$SUBP == 1 & tree_list$DIA >= 5, ] |>
197236
calc_crown_overlay(sample_radius = 24)
198237
#> [1] 86.8
199238

200-
## calculate stand height metrics, which are also included by default in the
201-
## output of `calc_tcc_metrics()` (see below)
239+
## Calculate stand height metrics, which are also included by default in the
240+
## output of `calc_tcc_metrics()` (see below).
202241

203242
# compute stand height metrics only
204243
# calc_ht_metrics(plantation)
205244

206-
## predict plot-level canopy cover from individual tree measurements
245+
## Predict plot-level canopy cover from individual tree measurements.
207246

208-
# by default, TCC is predicted using the "stem-map" model, full output returned
247+
# By default, TCC is predicted using the "stem-map" model, full output returned.
209248
calc_tcc_metrics(plantation)
210249
#> $model_tcc
211250
#> [1] 88.4
@@ -282,25 +321,25 @@ calc_tcc_metrics(plantation)
282321
#> $maxSapHt
283322
#> [1] 43
284323

285-
# return only the predicted TCC value (`$model_tcc`)
324+
# Return only the predicted TCC value (`$model_tcc`).
286325
calc_tcc_metrics(plantation, full_output = FALSE)
287326
#> [1] 88.4
288327

289-
# using the "FVS method", which assumes that trees are randomly located
328+
# Using the "FVS method", which assumes that trees are randomly located.
290329
calc_tcc_metrics(plantation, stem_map = FALSE, full_output = FALSE)
291330
#> [1] 81.4
292331
```
293332

294333
### Data processing
295334

296335
``` r
297-
# load tree data from a file or database connection
298-
# Lolo NF, single-condition forest plots, INVYR 2022, from public FIADB
336+
# Load tree data from a file or database connection.
337+
# Lolo NF, single-condition forested plots, INVYR = 2022, from public FIADB
299338
f <- system.file("extdata/mt_lnf_2022_1cond_tree.csv", package="FIAstemmap")
300339
tree_table <- load_tree_data(f)
301-
#> ! the data source does not have DIST and/or AZIMUTH
302-
#> ℹ Fetching tree data...
303-
#> ✔ Fetching tree data. [14ms]
340+
#> ! The data source does not have DIST and/or AZIMUTH.
341+
#> ℹ Fetching tree data
342+
#> ✔ Fetching tree data [14ms]
304343
#>
305344
#> ℹ 910 tree records returned.
306345

401 Bytes
Loading
509 Bytes
Loading
20.8 KB
Loading
28.6 KB
Loading

0 commit comments

Comments
 (0)