Soil Classification


The USDA classifies soils into twelve types (called "textures"), based on their relative percentages of sand, silt, and clay; since these three percentages total 100, any soil sample can be plotted on a ternary graph: an equilateral triangle whose apexes represent pure sand, pure silt, and pure clay. Typically, these plots show the twelve soil textures as polygons superimposed on the triangle, like this:

Uploaded Image

I represent each texture by an instance of PolygonMorph; since a PolygonMorph can tell whether any specified point is within its boundry, I can classify any soil sample by asking each texture in turn "does this soil sample belong to you?"

Our Soil Classification app lets the user enter a project number, and then enter data for one or more soil samples associated with that project. The user can save the project's data to a persistent file (actually a stripped-down SDF file i.e. a headerless DBase table), or retrieve it from the file. He can display the data on screen as a ternary plot with a differently-shaped mark for each data point; the display includes a tabularly-formatted explanition of the data points. The data can also be printed on the user's choice of PostScript printers, or be saved as a PostScript file (actually, an Encapsulated PostScript file, but with no included preview); in these cases, the display is surrounded by a frame and has a title block (i.e. the printed version is suitable for inclusion in official reports).

Squeak had no PostScript support when I began this app (Squeak 2.2), so I built my own rudimentary PostScript support (the app's screen display uses only TextMorphs and PolygonMorphs, and each of these maps neatly to a simple fragment of PostScript code). Similarly, I built rudamentary database support (or rather, the ability to read and write simple database tables).

I wrote the first version of this app in an uncomfortable amalgam of Morphic and MVC; I am currently converting it to a wholly Morphic app, based on Bob's UI.

Return to home page