I'm using R's soilDB SSURGO library to generate a soil characteristic report (pH, soil type, drainage properties, etc.) for a given lat/long, but I can't figure out how to get the 1st and 2nd horizon data for pH, clay, sand, etc. I can get only so far and then I am stumped by the documentation. Here is my progress:

For a given a latitude or longitude, e.g. 27.891051,-82.288567:

  p <- SpatialPoints(cbind( longitude,latitude), proj4string = CRS('+proj=longlat +datum=WGS84'))
  # transform to planar coordinate system for buffering
  p.aea <- spTransform(p, CRS('+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-96 +x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m +no_defs '))
  # create 150 meter buffer
  p.aea <- gBuffer(p.aea, width = 100)
  # transform back to WGS84 G
  p.buff <- spTransform(p.aea, CRS('+proj=longlat +datum=WGS84'))
  # convert to WKT
  p.wkt <- writeWKT(p.buff)

  q <- paste0("SELECT mukey, muname
  FROM mapunit
  WHERE mukey IN (
  SELECT * from SDA_Get_Mukey_from_intersection_with_WktWgs84('", p.wkt, "')

  res <- SDA_query(q)

returns res

    mukey                                             muname
1 1406998 Basinger, Holopaw, and Samsula soils, depressional
2 1407011             Zolfo fine sand, 0 to 2 percent slopes

Let's say we pick mukey 1407011 and look up that cokey:

q <- "SELECT *
    FROM component
    WHERE mukey = '%s'"

    # run the query
    res <- SDA_query(sprintf(q,mukey))

res returns the mukeys as:

comppct_l comppct_r comppct_h compname compkind majcompflag otherph localphase slope_l slope_r slope_h slopelenusle_l slopelenusle_r slopelenusle_h
1        80        85        90    Zolfo   Series         Yes      NA         NA       0       1       2             30             61             91
    runoff tfact wei weg   erocl earthcovkind1                     earthcovkind2 hydricon hydricrating              drainagecl elev_l elev_r elev_h
1 Very low     5 250   1 Class 1    Tree cover Intermixed conifers and hardwoods     <NA>           No Somewhat poorly drained      8     20     50
  aspectccwise aspectrep aspectcwise                                                                                   geomdesc albedodry_l albedodry_r
1            0       200         360 rises on marine terraces on coastal plains, flatwoods on marine terraces on coastal plains          NA         0.3
  albedodry_h airtempa_l airtempa_r airtempa_h map_l map_r map_h reannualprecip_l reannualprecip_r reannualprecip_h ffd_l ffd_r ffd_h nirrcapcl nirrcapscl
1          NA         20         23         25  1118  1270  1422               NA               NA               NA   350   360   365         3          w
  nirrcapunit irrcapcl irrcapscl irrcapunit cropprodindex constreeshrubgrp wndbrksuitgrp rsprod_l rsprod_r rsprod_h foragesuitgrpid wlgrain wlgrass
1          NA       NA        NA         NA            NA             1ssa            NA     3000     4000     6000              NA      NA      NA
  wlherbaceous wlshrub wlconiferous wlhardwood wlwetplant wlshallowwat wlrangeland wlopenland wlwoodland wlwetland soilslippot frostact initsub_l initsub_r
1           NA      NA           NA         NA         NA           NA          NA         NA         NA        NA          NA     None         0         0
  initsub_h totalsub_l totalsub_r totalsub_h hydgrp corcon corsteel                                         taxclname  taxorder taxsuborder taxgrtgroup
1         0          0          0          0      A   High     High Sandy, siliceous, hyperthermic Oxyaquic Alorthods Spodosols     Orthods   Alorthods
           taxsubgrp taxpartsize taxpartsizemod taxceactcl taxreaction    taxtempcl taxmoistscl taxtempregime  soiltaxedition castorieindex flecolcomnum
1 Oxyaquic Alorthods       sandy       not used   not used    not used hyperthermic    Oxyaquic  hyperthermic twelfth edition            NA            6
  flhe flphe flsoilleachpot flsoirunoffpot fltemik2use fltriumph2use indraingrp innitrateleachi misoimgmtgrp vasoimgtgrp   mukey    cokey
1   NA    NA         Medium            Low         Yes           Yes         NA              NA           NA          NA 1407011 18985410

This returns as cokey of 18985410, but I can't figure out what to do next.

1 Answer 1


I needed to use fetchSDA_component. Here is sample code that extracts the median physical soil properties from the top two soil horizons:

test = fetchSDA_component(WHERE = paste0("mukey=",mukey),duplicates = FALSE, childs = TRUE, rmHzErrors = FALSE)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.