diff --git a/R/createSSURGO.R b/R/createSSURGO.R index eda512a9..2a2c3a7e 100644 --- a/R/createSSURGO.R +++ b/R/createSSURGO.R @@ -200,6 +200,7 @@ createSSURGO <- function(filename, if (!is.null(msidxdet)) { indexPK <- na.omit(msidxdet[[4]][msidxdet[[1]] == mstab_lut[x] & grepl("PK_", msidxdet[[2]])]) + indexDI <- na.omit(msidxdet[[4]][msidxdet[[1]] == mstab_lut[x] & grepl("DI_", msidxdet[[2]])]) } d <- try(as.data.frame(data.table::rbindlist(lapply(seq_along(f.txt.grp[[x]]), function(i) { @@ -241,6 +242,16 @@ createSSURGO <- function(filename, }, silent = quiet) } + # create key indices + if (!is.null(indexDI) && length(indexDI) > 0) { + for (i in seq_along(indexDI)) { + try({ + RSQLite::dbExecute(con, sprintf("CREATE INDEX IF NOT EXISTS %s ON %s (%s)", + paste0('DI_', mstab_lut[x]), mstab_lut[x], indexDI[i])) + }, silent = quiet) + } + } + # for GPKG output, add gpkg_contents (metadata for features and attributes) if (IS_GPKG) { # update gpkg_contents table entry