Soil Property Scripts National Soil Survey Center.

24
Soil Property Scripts National Soil Survey Center

Transcript of Soil Property Scripts National Soil Survey Center.

Page 1: Soil Property Scripts National Soil Survey Center.

Soil Property Scripts

National Soil Survey Center

Page 2: Soil Property Scripts National Soil Survey Center.

Preliminaries Refresh your local

database Clear your

selected set Use the Pangaea

query called: “Area/Lmap/Mapunit/MajorComp by AreaSym, AreaType”

Target “Legend” against the national database

Area type nat* Area symbol

Interps Run it

Page 3: Soil Property Scripts National Soil Survey Center.

Preliminaries Use the same

query against your local database

Target Area, Legend mapunit, correlation, and component

Areatype name nat*

Area symbol Interps

Run it

Page 4: Soil Property Scripts National Soil Survey Center.

Preliminaries Use the Pangaea

query Component by COKEY the national database

Set the Cokey to 775215

Target datamapunit Run it Against the local

database, use same cokey against the component table

Run it Select that

component in the Component Table

Page 5: Soil Property Scripts National Soil Survey Center.

Function of Soil Property Scripts

Provide data for interpretations, a “high”, “low”, and “rv”, one value for each, thus a main feature of property scripts is some variety of aggregation

Provide data for report scripts Act like a subroutine Normally aggregate columns, row

aggregation is performed in the main SQL Property scripts are executed for one

component at a time as the report cycles. This has ramifications for map unit aggregated reports.

Page 6: Soil Property Scripts National Soil Survey Center.

Anatomy of a Simple Script

Property Name: Must be unique per NASIS Site

Description: Tells user what the script is meant to do.

Data Type: Tells what kind of data is being retrieved

Modality: Tells how many items

Default Value: We try not to use any more

Character or Numeric

High and LowHigh, Low, and RVRV

Page 7: Soil Property Scripts National Soil Survey Center.

Anatomy of a simple script

You have seen “Base Table” with Paul. It becomes very evident what “Base Table” does when you realize there are no tables listed above component. All the coordination is done elsewhere.

Exec sql acts just as in a report.

Select is the same also

This property will only retrieve the representative value of frost free days from the component table.

Property scripts MUST produce at least an RV, by DEFINE or alias

Push the green button when a component is highlighted and the property runs

Page 8: Soil Property Scripts National Soil Survey Center.

Data Aggregation in the SQLThis script: Makes this output:

Note aggregation of “none”

Note a value for each layer.

These are arrays of data, which we will look at more closely later.

Page 9: Soil Property Scripts National Soil Survey Center.

Data Aggregation in the SQL

This script: Makes this output:

Note aggregation of “none”

Note a value for each layer.

These are arrays of data, which we will look at more closely later.

Page 10: Soil Property Scripts National Soil Survey Center.

Data Aggregation in the SQLThis script: Makes this output:

Since default aggregation is “unique”, any repeats are combined.

Page 11: Soil Property Scripts National Soil Survey Center.

Data Aggregation in the SQLThis script: Makes this output:

Since default aggregation is “unique”, any repeats are combined.

Page 12: Soil Property Scripts National Soil Survey Center.

Data Aggregation in the SQLThis script: Makes this output:

Since default aggregation is “unique”, any repeats are combined.

Other aggregation types are max, min, last, unique, sum, list, and a few others. Usually use “none” to preserve all the data for future use.

Page 13: Soil Property Scripts National Soil Survey Center.

Deriving data using other properties

This script: Makes this output:

Since default aggregation is “unique”, any repeats are combined.

Other aggregation types are max, min, last, unique, sum, list, and a few others. Usually use “none” to preserve all the data for future use.

This is a “called” property

Page 14: Soil Property Scripts National Soil Survey Center.

Derive data

Advantages Script is less cluttered Reduces amount of

typing Helps control

aggregation problems

Disadvantages Longer run time Might hide some

unexpected conditions, for example might mismatch restriction kinds with the main property

Page 15: Soil Property Scripts National Soil Survey Center.

Data Aggregation using Define, Array functions

ARRAYMIN ARRAYMAX ARRAYMEDIAN ARRAYMODE

In the context of properties, these are used mainly to aggregate horizon table data to get one number for a component

Page 16: Soil Property Scripts National Soil Survey Center.

Data Aggregation: DEFINE Array Functions

This script: Makes this output:

Page 17: Soil Property Scripts National Soil Survey Center.

Data Aggregation: Weighted Average

This script: Makes this output:

These arrays must be the same size!!

Page 18: Soil Property Scripts National Soil Survey Center.

Data Aggregation: LookupThis script: Makes this output:

“arraymax” finds the thickest layer, the “lookup” finds the pct_r that is associated with that layer

Page 19: Soil Property Scripts National Soil Survey Center.

Data Aggregation below the Horizon table

This script: Makes this output:

“arraymax” finds the thickest layer, the “lookup” finds the pct_r that is associated with that layer

If you try to aggregate this script in the SQL or by using an array function, you will get just one number for each column from the whole component, but what we want to do here is find a volumetric CEC. So we need to account for the rock fragments by layer.

We would like to combine the rock fragment volumes by layer to adjust the CEC. The answer is REGROUP.

Page 20: Soil Property Scripts National Soil Survey Center.

Data Aggregation below the Horizon table: REGROUP

This script: Makes this output:

REGROUP of fragments by layer using the SUM method of aggregation. Careful attention is needed to get the syntax correct using REGROUP. Other REGROUP options are AVERAGE, FIRST, LAST, MIN, MAX, and LIST

Properties usually iterate on the base table component, so a device like regroup is needed to give an ability to aggregate at a deeper level.

Page 21: Soil Property Scripts National Soil Survey Center.
Page 22: Soil Property Scripts National Soil Survey Center.

Assignment

WTD_AVG CLAY CONTENT 25-180cm OR ABOVE RESTRICTION

Make the above script return the weighted average total sand content from 15 to 100cm.

Page 23: Soil Property Scripts National Soil Survey Center.

Reporting Property Output

No mapunit aggregation

Map unit aggregation

INTERP - (NAT) Single Property Script Representative Values

UTIL - (NAT) MU Aggregated Property Data (Dom Comp)

INTERP – (NAT) Property Script Output, Numeric, MU Aggregated

Page 24: Soil Property Scripts National Soil Survey Center.

That can’t be done?