# \donttest{
require(ggplot2)
require(sf)
extd.dir <- system.file("extdata", package = "apsimx")
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 <- st_read(paste0(extd.dir,"/ISUAG/SSURGO/ISUAG_SSURGO_Mapunits.shp"), quiet = TRUE)
## Using default 'constant' method
sp.c <- ssurgo2sp(mapunit = mapunit,
component = component,
chorizon = chorizon,
mapunit.shp = mapunit.shp)
sp.c <- sp.c[[1]]
ggplot(data = sp.c, aes(y = -Depth, x = Carbon)) +
geom_point() +
geom_path() +
ylab("Soil Depth (cm)") + xlab("Organic Matter (percent)") +
ggtitle("method = constant")
## Using 'linear' method
sp.l <- ssurgo2sp(mapunit = mapunit,
component = component,
chorizon = chorizon,
mapunit.shp = mapunit.shp,
method = "linear")
sp.l <- sp.l[[1]]
ggplot(data = sp.l, aes(y = -Depth, x = Carbon)) +
geom_point() +
geom_path() +
ylab("Soil Depth (cm)") + xlab("Organic Matter (percent)") +
ggtitle("Method linear")
# }
if (FALSE) {
## Method using get_ssurgo_tables
require(soilDB)
require(sp)
require(sf)
require(spData)
## retrieve data from lon -93, lat = 42
stbls <- get_ssurgo_tables(lonlat = c(-93, 42))
sp2.c <- ssurgo2sp(mapunit = stbls$mapunit,
component = stbls$component,
chorizon = stbls$chorizon,
mapunit.shp = stbls$mapunit.shp)
names(sp2.c)
metadata <- attributes(sp2.c[[1]])
metadata$names <- NULL; metadata$class <- NULL; metadata$row.names <- NULL
## Convert to an APSIM soil profile
asp2.c <- apsimx_soil_profile(nlayers = 10,
Thickness = sp2.c[[1]]$Thickness * 10,
BD = sp2.c[[1]]$BD,
AirDry = sp2.c[[1]]$AirDry,
LL15 = sp2.c[[1]]$LL15,
DUL = sp2.c[[1]]$DUL,
SAT = sp2.c[[1]]$SAT,
KS = sp2.c[[1]]$KS,
Carbon = sp2.c[[1]]$Carbon,
PH = sp2.c[[1]]$PH,
ParticleSizeClay = sp2.c[[1]]$ParticleSizeClay,
ParticleSizeSilt = sp2.c[[1]]$ParticleSizeSilt,
ParticleSizeSand = sp2.c[[1]]$ParticleSizeSand,
metadata = metadata)
plot(asp2.c)
plot(asp2.c, property = "water")
}
Run the code above in your browser using DataLab