Soil is made up of the following three soil components:
Soil texture is often presented using the ratios (or percentages) of the 3 soil components. The 3 ratios must add to 1.0 (or 100%).
I built a set of functions to allow the categorization and plotting of soils.
I built the general application using Plotly. First, I programmed in Python using Jupyter Lab, then I ported the categorization functions to PyXLL.
I learned a few things along the way:
- Triangulate the category polygons using the input point as a hub in conjunction with all polygon vertices: if the sum of the triangle areas equals the polygon area, then the input point is within the polygon.
As an example, visualize an input point within the category ‘loam’. Make that input point into a hub and draw 5 lines out to the ‘loam’ polygon vertices. Sum the absolute value(area) for the 5 resulting triangles. Compare that sum to the area of the ‘loam’ polygon: if the two areas are equal then input point is within the polygon.
- Determine the winding number for the input point: if the winding number is non-zero then the input point is within the polygon.
- Using the first approach, I wrote my own triangulation algorithm and it works.
- However, the second approach is faster and is more elegant.
Thank you to Dan Sunday
and Jacob Rus
for their posts regarding winding numbers.
Thank you to Cyrille Ka for his post regarding determining if a point C is on the line segment defined by A and B.