Mast head image

Rusle2, WEPS, and APEX Data

This script retrieves the data for Rusle2, WEPS, and the APEX programs.


Text highlighted in yellow in the example script can be changed for a particular area, or you can use wildcards to get an entire State. Examples can be found on the Tips page.

Tips Page

Copy the example script below and paste it into the query page on the Soil Data Access site.

Soil Data Access Query Page

Example Script

SELECT sa.saversion, sa.saverest, l.areasymbol, l.areaname, mu.mukey, mu.musym, mu.muacres,

c.comppct_r, c.compname, localphase, taxorder,slope_r,

CASE WHEN nirrcapscl IS NULL THEN nirrcapcl ELSE nirrcapcl + nirrcapscl END AS capclass,

drainagecl, hydgrp, tfact, slopelenusle_r, albedodry_r,

(SELECT TOP 1 taxminalogy FROM cotaxfmmin WHERE cotaxfmmin.cokey=c.cokey) AS mineralogy,

(SELECT CASE WHEN MIN(resdept_r) IS NULL THEN '>200' ELSE CAST(MIN(resdept_r) AS VARCHAR) END

FROM component

LEFT OUTER JOIN corestrictions ON component.cokey = corestrictions.cokey

WHERE component.cokey = c.cokey AND reskind IS NOT NULL) AS restrictiondepth,

(SELECT TOP 1 reskind

FROM component

LEFT OUTER JOIN corestrictions ON component.cokey = corestrictions.cokey

WHERE component.cokey = c.cokey AND reskind IS NOT NULL) AS restrictionkind,

hzname, hzdept_r, hzdepb_r, texture, claytotal_r, silttotal_r, sandtotal_r,

sandvc_r, sandco_r, sandmed_r, sandfine_r, sandvf_r,

(SELECT CASE WHEN SUM(cf.fragvol_r) IS NULL THEN '0' ELSE CAST(SUM(cf.fragvol_r) AS VARCHAR) END

FROM chfrags cf WHERE cf.chkey = ch.chkey) AS fragvol,

kffact, dbthirdbar_r, dbovendry_r, ksat_r, cec7_r, ph1to1h2o_r, wtenthbar_r, wthirdbar_r, wfifteenbar_r,

awc_r, om_r, ec_r, lep_r, caco3_r, sumbases_r,

(SELECT CASE WHEN MAX(soimoistdept_r) IS NULL THEN '>200' ELSE CAST(MAX(soimoistdept_r) AS VARCHAR) END

FROM component

LEFT OUTER JOIN comonth ON comonth.cokey = component.cokey

LEFT OUTER JOIN cosoilmoist ON comonth.comonthkey = cosoilmoist.comonthkey

WHERE component.cokey = c.cokey AND soimoiststat = 'Wet'

AND ((taxtempregime IN ('Cryic', 'Pergelic') AND comonth.month IN ('July', 'August'))

OR (taxtempregime IN ('Frigid', 'Mesic', 'Isofrigid') AND comonth.month IN ('May', 'June', 'July', 'August', 'September'))

OR (taxtempregime IN ('Thermic', 'Hyperthermic') AND comonth.month IN ('April', 'May', 'June', 'July', 'August', 'September', 'October'))

OR (taxtempregime IN ('Isothermic', 'Isohyperthermic', 'Isomesic') AND comonth.month IN ('March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November')))) AS maxgswatertable_r,

(SELECT CASE WHEN MIN(soimoistdept_r) IS NULL THEN '>200' ELSE CAST(MIN(soimoistdept_r) AS VARCHAR) END

FROM component

LEFT OUTER JOIN comonth ON comonth.cokey = component.cokey

LEFT OUTER JOIN cosoilmoist ON comonth.comonthkey = cosoilmoist.comonthkey

WHERE component.cokey = c.cokey AND soimoiststat = 'Wet'

AND ((taxtempregime IN ('Cryic', 'Pergelic') AND comonth.month IN ('July', 'August'))

OR (taxtempregime IN ('Frigid', 'Mesic', 'Isofrigid') AND comonth.month IN ('May', 'June', 'July', 'August', 'September'))

OR (taxtempregime IN ('Thermic', 'Hyperthermic') AND comonth.month IN ('April', 'May', 'June', 'July', 'August', 'September', 'October'))

OR (taxtempregime IN ('Isothermic', 'Isohyperthermic', 'Isomesic') AND comonth.month IN ('March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November')))) AS mingswatertable_r, c.cokey, ch.chkey

FROM legend l

INNER JOIN mapunit mu ON mu.lkey = l.lkey

LEFT OUTER JOIN sacatalog sa ON sa.areasymbol = l.areasymbol

LEFT OUTER JOIN component c ON c.mukey = mu.mukey

LEFT OUTER JOIN chorizon ch ON ch.cokey = c.cokey

LEFT OUTER JOIN chtexturegrp ct ON ch.chkey=ct.chkey

WHERE compkind != 'miscellaneous area' AND ct.rvindicator = 'yes' AND l.areasymbol= 'MO123'

ORDER BY areasymbol, musym, comppct_r DESC, hzdept_r

Example Table Output

Column headers were not changed from the original script.

Description of tables and columns can be found on this link: Table and Column Descriptions

saversion saverest areasymbol areaname mukey musym muacres comppct_r compname localphase taxorder slope_r capclass drainagecl hydgrp tfact slopelenusle_r albedodry_r mineralogy restrictiondepth restrictionkind hzname hzdept_r hzdepb_r texture claytotal_r silttotal_r sandtotal_r sandvc_r sandco_r sandmed_r sandfine_r sandvf_r fragvol kffact dbthirdbar_r dbovendry_r ksat_r cec7_r ph1to1h2o_r wtenthbar_r wthirdbar_r wfifteenbar_r awc_r om_r ec_r lep_r caco3_r sumbases_r maxgswatertable_r mingswatertable_r cokey chkey
18 9/28/2016 6:29:28 PM MO123 Madison County, Missouri 2501597 73055 4088 50 Alred Alfisols 25 6s Well drained C 4 15 0.23 siliceous 56 Strongly contrasting textural stratification Oi 0 2 SPM 9.9 76.5 13.6 4.2 2.1 1.8 2.7 2.8 19 0.3 0.4 91 5.4 36.5 13.2 0.1 50 0.4 0 16.6 >200 >200 14025732 40311245



Helping People Help the Land

USDA is an equal opportunity provider, employer, and lender.