Skip to content

Commit

Permalink
dmu-summary v0.4
Browse files Browse the repository at this point in the history
 - implement parameter for custom cache files
 - other minor adjustments
 - update README/NASIS instructions
  • Loading branch information
brownag committed Nov 15, 2024
1 parent 30cf7e7 commit 263e8a6
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 104 deletions.
18 changes: 6 additions & 12 deletions inst/reports/region2/dmu-summary/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
# DMU Summary Report
PENDING

## Typical Usage
This report requires setting up a selected set in your local NASIS database:

* load legend by area symbol
* load related MU (approved / provisional only)
* load related DMU (rep DMU only)
* load related component pedons
* load related site observation
## Usage

Run the following commands to setup the report template.

```r
# load this library
library(soilReports)
Expand All @@ -22,9 +15,10 @@ reportSetup(reportName='region2/dmu-summary')
reportInit(reportName='region2/dmu-summary', outputDir='dmu-summary')
```

TODO: Setup `cached.rds`.
This report requires loading several related objects into your NASIS Selected Set, including Area, Legend Mapunit, Correlation, Component Pedon, Pedon and Site Observation.

TODO: specification of map unit symbol via `params`
A useful NASIS query that gets all of the necessary objects is **_NSSC Pangaea_: _Area/Legend/Mapunit/DMU/Pedon/Site by areasymbol_**.

Open `report.Rmd` and then click "knit".
- This query has detailed instructions for loading necessary data, and includes only representative data map units. Several other variants of this same query can be used to obtain data based on component or pedon information rather than area symbol.

Open `report.Rmd`, review the "params" section of the YAML header to select target mapunit and cache file name, then click "knit". You can cache the data for many map units (e.g. a whole soil survey area) once, then re-run the report several times with different `musym` values. To force new data to be loaded from the database, delete the .rda file specified in `cache_file` in the document directory.
2 changes: 1 addition & 1 deletion inst/reports/region2/dmu-summary/cache-data.R
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,6 @@ cm <- cm[, c('.label', 'comppct_r', cm.names)]
# TODO: re-level component names based on mean comppct

## save
save(co, cm, p, cp, osds, cotx, geom, pm, file = 'data.rda')
save(co, cm, p, cp, osds, cotx, geom, pm, file = params$cache_file)


9 changes: 7 additions & 2 deletions inst/reports/region2/dmu-summary/config.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,17 @@
.label = 'CA792',
variable = factor(
c('elev', 'ffd', 'maat', 'map', 'slope'),
labels = c('Elevation (m)', 'Frost-Free Days', 'MAAT (deg C)', 'MAP (mm)', 'Slope (%)')
labels = c(
'Elevation (m)',
'Frost-Free Days',
'MAAT (deg C)',
'MAP (mm)',
'Slope (%)'
)
),
rv = c(3005, 83, 3.28, 984, 43),
low = c(1469, 40, -1.02, 583, 8),
high = c(3728, 193, 12.01, 1381, 99)

)


8 changes: 4 additions & 4 deletions inst/reports/region2/dmu-summary/custom.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@
#'
#' # simplest case, use a SPC
#' data("jacobs2000")
#' emtpySPC(jacobs2000)
#' emptySPC(jacobs2000)
#'
#' # convert to SPC with data.table internals
#' x <- jacobs2000
#' aqp_df_class(x) <- 'data.table'
#' x <- rebuildSPC(x)
#'
#' emtpySPC(x)
#' emptySPC(x)
#'
#' # convert to SPC with tibble internals
#' x <- jacobs2000
#' aqp_df_class(x) <- 'tibble'
#' x <- rebuildSPC(x)
#'
#' emtpySPC(x)
#' emptySPC(x)
#'
emtpySPC <- function(x, fakeID = 'MISSING', top = 0, bottom = max(x)) {
emptySPC <- function(x, fakeID = 'MISSING', top = 0, bottom = max(x)) {

# use the first profile / horizon
# as template
Expand Down
Loading

0 comments on commit 263e8a6

Please sign in to comment.