Learn R Programming

soilDB (version 2.5)

fetchNASISLabData: Fetch lab data used site/horizon data from a PedonPC database.

Description

Fetch KSSL laboratory pedon/horizon layer data from a local NASIS database, return as a SoilProfileCollection object.

Usage

fetchNASISLabData(SS = TRUE)

Arguments

SS

fetch data from the currently loaded selected set in NASIS or from the entire local database (default: TRUE)

Value

a SoilProfileCollection class object

Details

This function currently works only on Windows, and requires a 'nasis_local' ODBC connection.

See Also

get_labpedon_data_from_NASIS_db

Examples

Run this code
# NOT RUN {
  # check required packages
  if(require(aqp) & requireNamespace("RODBC")) {

    # test that NASIS db connection is set up
    # note that you must setup this connection ahead of time
    # see inst/doc/setup_ODBC_local_NASIS.pdf
    if(any(grepl(names(RODBC::odbcDataSources()), pattern="nasis_local"))) {
      
      # query depends on some lab data, queried against the national database
      f <- try(fetchNASISLabData())
      # note: wrap in try in case no lab data in selected set
    
      # plot only those profiles with densic contact
      if(!inherits(f,'try-error')) {
      
        # which pedons have densic.contact==TRUE
        idx <- which(f$densic.contact)
        
        # if there are any pedons with densic contacts, plot them
        if(length(idx))
          plot(f[idx, ], name='hzname')
    
      } else { message(f[1]) }
    }
  }
# }

Run the code above in your browser using DataLab