Skip to contents

This is an efficient method for spatially merging several different soil survey areas as well as merging their tabular data.

Usage

get_ssurgo(
  template,
  label,
  raw.dir = paste0(tempdir(), "/FedData/raw/ssurgo"),
  extraction.dir = paste0(tempdir(), "/FedData/"),
  force.redo = FALSE
)

Arguments

template

An Simple Feature or SpatRaster object to serve as a template for cropping. Optionally, a vector of area names, e.g., c('IN087','IN088') may be provided.

label

A character string naming the study area.

raw.dir

A character string indicating where raw downloaded files should be put. The directory will be created if missing. Defaults to './RAW/SSURGO/'.

extraction.dir

A character string indicating where the extracted and cropped SSURGO shapefiles should be put. The directory will be created if missing. Defaults to './EXTRACTIONS/SSURGO/'.

force.redo

If an extraction for this template and label already exists, should a new one be created? Defaults to FALSE.

Value

A named list containing the 'spatial' and 'tabular' data.

Details

get_ssurgo returns a named list of length 2:

  1. 'spatial': A Simple Feature of soil mapunits in the template, and

  2. 'tabular': A named list of data.frames with the SSURGO tabular data.

Examples

# \donttest{
# Get the NRCS SSURGO data (USA ONLY)
SSURGO.MEVE <-
  get_ssurgo(template = FedData::meve,
             label = "meve")
#> (Down)Loading SSURGO data for survey area CO670
#> Downloading file: http://websoilsurvey.sc.egov.usda.gov/DSD/Download/Cache/SSA/wss_SSA_CO670_[2024-08-29].zip
#> (Down)Loading SSURGO data for survey area CO671
#> Downloading file: http://websoilsurvey.sc.egov.usda.gov/DSD/Download/Cache/SSA/wss_SSA_CO671_[2024-08-29].zip

# Plot the VEP polygon
plot(meve)

# Plot the SSURGO mapunit polygons
plot(SSURGO.MEVE$spatial['MUKEY'], 
     lwd = 0.1, 
     add = TRUE)


# Or, download by Soil Survey Area names
SSURGO.areas <- 
  get_ssurgo(
    template = c("CO670", "CO075"), 
    label = "CO_TEST"
  )
#> (Down)Loading SSURGO data for survey area CO075
#> Downloading file: http://websoilsurvey.sc.egov.usda.gov/DSD/Download/Cache/SSA/wss_SSA_CO075_[2024-08-29].zip
#> (Down)Loading SSURGO data for survey area CO670
#> Local file exists. Returning.

# Let's just look at spatial data for CO675
SSURGO.areas.CO675 <- 
  SSURGO.areas$spatial[SSURGO.areas$spatial$AREASYMBOL == "CO075", ]

# And get the NED data under them for pretty plotting
NED.CO675 <- 
  get_ned(
    template = SSURGO.areas.CO675, 
    label = "SSURGO_CO675"
  )
#> Area of interest includes 4 NED tiles.
#> (Down)Loading NED tile for 41N and 103W.
#> (Down)Loading NED tile for 42N and 103W.
#> (Down)Loading NED tile for 41N and 104W.
#> (Down)Loading NED tile for 42N and 104W.
#> Mosaicking NED tiles.
#> ext 0: -103.582 -103.349 40.8133 41.0025 
#> ext 1: -103.582 -103.349 40.8133 41.0025 
#> ext 0: -103.349 -103.116 40.8133 41.0025 
#> ext 1: -103.349 -103.116 40.8133 41.0025 
#> ext 0: -103.116 -102.883 40.8133 41.0025 
#> ext 1: -103.116 -102.883 40.8133 41.0025 
#> ext 2: -103.116 -102.883 40.8133 41.0025 
#> ext 3: -103.116 -102.883 40.8133 41.0025 
#> ext 0: -102.883 -102.651 40.8133 41.0025 
#> ext 1: -102.883 -102.651 40.8133 41.0025 
#> ext 0: -103.582 -103.349 40.6242 40.8133 
#> ext 0: -103.349 -103.116 40.6242 40.8133 
#> ext 0: -103.116 -102.883 40.6242 40.8133 
#> ext 1: -103.116 -102.883 40.6242 40.8133 
#> ext 0: -102.883 -102.651 40.6242 40.8133 
#> ext 0: -103.582 -103.349 40.4353 40.6242 
#> ext 0: -103.349 -103.116 40.4353 40.6242 
#> ext 0: -103.116 -102.883 40.4353 40.6242 
#> ext 1: -103.116 -102.883 40.4353 40.6242 
#> ext 0: -102.883 -102.651 40.4353 40.6242 

# Plot the SSURGO mapunit polygons, but only for CO675
terra::plot(NED.CO675)
plot(
  SSURGO.areas.CO675$geom, 
  lwd = 0.1, 
  add = TRUE
  )

# }