Learn to query SSURGO from scratch. No SQL experience required. Five lessons, each with live examples you run against the real SDA API.
Understanding the tables before you query them
SSURGO is organized as a hierarchy of four core tables. Understanding how they relate to each other is the most important thing you can learn before writing a single query.
legend (survey areas — the "where")
└── mapunit (map units — polygon footprints)
└── component (soil types within a map unit)
└── chorizon (individual horizon layers)
legend (pick your area), join to mapunit (what's on the map), join to component (what soil it is), then chorizon (layer by layer properties).lkey — joins legend to mapunitmukey — joins mapunit to component and muaggattcokey — joins component to chorizon and cointerpareasymbol — like "WI025" = Dane County, Wisconsinmajcompflag — "Yes" = this is the dominant soil typeSELECT, FROM, TOP — returning map unit names
The three most essential SQL keywords: SELECT (what columns), FROM (which table), TOP (how many rows). Every query you write will start here.
SELECT TOP 10 -- return only 10 rows column1, column2 FROM table_name ORDER BY column1 -- sort results
TOP 10 or TOP 100 while exploring — otherwise you may get thousands of rows back.Finding soils by state, survey area, or property
WHERE narrows your results. The most powerful tool in soil queries is filtering by areasymbol to target a specific county, or by LIKE 'WI%' to match a whole state.
WHERE areasymbol = 'WI025' — exact countyWHERE areasymbol LIKE 'WI%' — all Wisconsin countiesWHERE muacres > 1000 — numeric comparisonWHERE drainagecl IN ('Well drained','Moderately well drained') — list matchORDER BY, COUNT — summarizing your results
Counting and sorting are the foundation of analysis. COUNT(*) tells you how many rows exist. GROUP BY groups them. ORDER BY DESC puts the biggest first.
Every map unit has a dominant soil — here's how to find it
A map unit contains multiple soil components — different soils that coexist within the same polygon. The dominant component is the one with the highest comppct_r (component percent). Use majcompflag = 'Yes' to filter to major components only.
compname (soil series name), comppct_r (% coverage), drainagecl (drainage class), hydgrp (A/B/C/D runoff group), taxclname (full taxonomy).Add JOINs across all four tables, aggregate with GROUP BY, and calculate your first real soil property: Available Water Storage.