R Under development (unstable) (2024-08-17 r87027 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > ## Testing the essence of the ssurgo workflow > require(apsimx) Loading required package: apsimx APSIM(X) not found. If APSIM(X) is installed in an alternative location, set paths manually using 'apsimx_options' or 'apsim_options'. You can still try as the package will look into the registry (under Windows) > require(sf) Loading required package: sf Linking to GEOS 3.12.1, GDAL 3.8.4, PROJ 9.3.1; sf_use_s2() is TRUE > apsimx_options(warn.versions = FALSE) > > extd.dir <- system.file("extdata", package = "apsimx") > > run.test.ssurgo.workflow <- get(".run.local.tests", envir = apsimx.options) > > tmp.dir <- tempdir() > > if(run.test.ssurgo.workflow){ + + ## Read the main files + chorizon <- read.csv(paste0(extd.dir,"/ISUAG/SSURGO/ISUAG_SSURGO_chorizon.csv")) + component <- read.csv(paste0(extd.dir,"/ISUAG/SSURGO/ISUAG_SSURGO_component.csv")) + mapunit <- read.csv(paste0(extd.dir,"/ISUAG/SSURGO/ISUAG_SSURGO_mapunit.csv")) + mapunit.shp <- sf::st_read(paste0(extd.dir,"/ISUAG/SSURGO/ISUAG_SSURGO_Mapunits.shp"), quiet = TRUE) + + ## Get tables from SSURGO + srgtbls <- get_ssurgo_tables(lonlat = c(-93, 42)) + chorizon <- srgtbls$chorizon + component <- srgtbls$component + mapunit <- srgtbls$mapunit + mapunit.shp <- srgtbls$mapunit.shp + + sp <- ssurgo2sp(mapunit = mapunit, + component = component, + chorizon = chorizon, + mapunit.shp = mapunit.shp, + nlayers = 20) + + ## For first soil + metadata <- attributes(sp[[1]]) + metadata$names <- NULL; metadata$class <- NULL; metadata$row.names <- NULL; + + asp <- apsimx_soil_profile(nlayers = 20, + Thickness = sp[[1]]$Thickness * 10, + BD = sp[[1]]$BD, + AirDry = sp[[1]]$AirDry, + LL15 = sp[[1]]$LL15, + DUL = sp[[1]]$DUL, + SAT = sp[[1]]$SAT, + KS = sp[[1]]$KS, + Carbon = sp[[1]]$Carbon, + crop.LL = sp[[1]]$LL15, + soil.bottom = 200, + metadata = metadata) + + check_apsimx_soil_profile(asp) + + edit_apsimx_replace_soil_profile("WheatRye.apsimx", + src.dir = extd.dir, + wrt.dir = tmp.dir, + soil.profile = asp, + edit.tag = "-sp") + + inspect_apsimx("WheatRye-sp.apsimx", src.dir = tmp.dir, node = "Soil") + + inspect_apsimx("WheatRye-sp.apsimx", src.dir = tmp.dir, + node = "Soil", soil.child = "Physical") + + ## If I want to actually run the model + file.copy(paste0(extd.dir,"/Ames.met"),tmp.dir) + + inspect_apsimx("WheatRye-sp.apsimx", src.dir = tmp.dir, node = "Clock") + + sim <- apsimx("WheatRye-sp.apsimx", src.dir = tmp.dir, value = "report") + + } > > if(run.test.ssurgo.workflow){ + + ## Testing the shift feature + stbls <- get_ssurgo_tables(lonlat = c(-82.97, 40.739), shift = 300) + stbls$mapunit$mukey + + sp0 <- ssurgo2sp(mapunit = stbls$mapunit, component = stbls$component, + chorizon = stbls$chorizon, mapunit.shp = stbls$mapunit.shp) + + stbls.sp <- get_ssurgo_soil_profile(lonlat = c(-82.97, 40.739), shift = 300) + + + } > > proc.time() user system elapsed 0.78 0.12 0.87