createSSURGO: Create a database from SSURGO Exports

View source: R/createSSURGO.R

createSSURGOR Documentation

Create a database from SSURGO Exports

Description

The following database types are tested and fully supported:

  • SQLite or Geopackage

  • DuckDB

  • Postgres or PostGIS

In theory any other DBI-compatible data source can be used for output. See conn argument. If you encounter issues using specific DBI connection types, please report in the soilDB issue tracker.

Usage

createSSURGO(
  filename,
  exdir,
  conn = DBI::dbConnect(DBI::dbDriver("SQLite"), filename, loadable.extensions = TRUE),
  pattern = NULL,
  include_spatial = TRUE,
  overwrite = FALSE,
  header = FALSE,
  quiet = TRUE,
  ...
)

Arguments

filename

Output file name (e.g. 'db.sqlite' or 'db.gpkg'). Only used when con is not specified by the user.

exdir

Path containing containing input SSURGO spatial (.shp) and tabular (.txt) files, downloaded and extracted by downloadSSURGO() or similar.

conn

A DBIConnection object. Default is a SQLiteConnection used for writing .sqlite or .gpkg files. Alternate options are any DBI connection types. When include_spatial=TRUE, the sf package is used to write spatial data to the database.

pattern

Character. Optional regular expression to use to filter subdirectories of exdir. Default: NULL will search all subdirectories for SSURGO export files.

include_spatial

Logical. Include spatial data layers in database? Default: TRUE.

overwrite

Logical. Overwrite existing layers? Default FALSE will append to existing tables/layers.

header

Logical. Passed to read.delim() for reading pipe-delimited (|) text files containing tabular data.

quiet

Logical. Suppress messages and other output from database read/write operations?

...

Additional arguments passed to write_sf() for writing spatial layers.

Value

Character. Vector of layer/table names in filename.

See Also

downloadSSURGO()

Examples

## Not run: 
 downloadSSURGO("areasymbol IN ('CA067', 'CA077', 'CA632')", destdir = "SSURGO_test")
 createSSURGO("test.gpkg", "SSURGO_test")

## End(Not run)

soilDB documentation built on June 22, 2024, 9:53 a.m.