New R Package 'aqp': Algorithms for Quantitative Pedology [updates]

Submitted by dylan on Mon, 2010-08-09 16:37.

Soils are routinely sampled and characterized according to genetic horizons (layers), resulting in data that are associated with principal dimensions: location (x,y), depth (z), and property space (p). The high dimensionality and grouped nature of this type of data can complicate standard analysis, summarization, and visualization. The aqp package was developed to address some of these issues, as well as provide a useful framework for the advancement of quantitative studies in soil genesis, geography, and classification.

The Algorithms for Quantitative Pedology (AQP) project was started as a place to put some of the functions I used on a daily basis. It slowly grew into a collection of algorithms that support studies related to soil genesis, taxonomy, and mapping. The short list of functionality includes:

  • classes for storing and manipulating soil profile data
  • functions for plotting soil profile sketches
  • color conversion functions (Munsell to RGB)
  • plotting functions for groups of soil profiles
  • plotting functions for depth-functions + uncertainty estimates
  • functions for re-sampling genetic horizons to regular sequences
  • profile aggregation functions
  • an implementation of between-profile dissimilarity calculation
  • functions for re-sampling XRD patterns to a common basis
  • functions for performing full-pattern matching of XRD patterns

Obviously, this project is far from an exhaustive implementation of what the name might otherwise suggest.

My reasoning for putting this package together is based on the premise that methods used by pedologists have grown with our understanding of natural systems and our ability to work with larger and larger datasets-- however, coupling of theory and practice to modern numerical methods is rare outside of academic circles. That is not to say that federal agencies and the soil science community are not catching up. Rather, it seems like the adoption of these new approaches can by hindered by a lack of an implementation that is more accessible than an article in a scientific journal. I am speaking from my experience in the western United States, therefore I apologies if I have not adequately described corresponding conditions in other parts of the world.

The naming of the package. It is currently named "Algorithms for Quantitative Pedology", inspired by Jenny's treatise on the topic. It could be argued that most modern pedologic studies (i.e. on the topic of soil genesis, morphology, classification, and mapping) are by and large a quantitative effort-- so this name may be more of a convenient acronym than descriptive label. In naming
this package I was hoping to encapsulate the idea of how modern numerical methods might be applied to the field of pedology. Well, the word "Pedometrics" does a pretty good job of conveying that idea. In particular, it falls well in line with Alex's initial description of Pedometrics: “the application of mathematical and statistical methods for the study of the distribution and genesis of soils”.

On the other hand, the potential for a diffuse interpretation of the word "Pedometrics" could lead to a package that lacks focus and ultimately critical mass. In that case, an entire suite of related R packages would likely work. There are several cases on CRAN / R-Forge where large efforts are split into several, related packages. In addition, the term 'Pedometrics' means many different things to many different people.

I would like to present a couple ideas on how this project, and extensions of it, might function as a liaison between rapid advances in the realm of Pedometrics and those interested in the application of these methods.

  1. R is an ideal environment for working with soils information and the packaging system is a robust approach to encapsulating code, documentation, and discussion.
  2. A suite of R packages, each geared towards a specific realm of what most soil scientists do (or would like to do) with their data, may be one way in which common work flows can be streamlined and better documented. These packages would be the vehicle by which theory, defined in academic journals, could be translated into well-documented tools for a wider range of practitioners.
  3. Within this suite, a master package (why not call it "pedometrics") could contain classes and utility functions for describing and manipulating objects that represent the complex structure of a soil profile. The companion packages would build on these common data structures and methods, making the implementation of newly discovered or experimental methods much simpler.
  4. The R-Forge system would facilitate concurrent access to the source code and documentation through the use of revision control. In this way, changes would be documented, and versions could be seamlessly forked or merged so that rapid development would not result in an unstable product.

Ultimately, I am interested in getting modern tools into the hands of current pedologists, and making it simpler for the adoption of these tools by new pedologists. If you are interested in these efforts, have comments or criticisms please don't hesitate to contact me. There is a vignette with an extended discussion on the AQP package, included in the package. I would encourage anyone that is interested to check the R-Forge site. A slightly older version is available on CRAN. Give the package a try by installing R, and then running:

# install the package
install.packages("aqp", repos="", dep=TRUE, type='source')

# load the package

# open the mini-manual

Hello! I have tested the new

Hello! I have tested the new aqp package and it-s great, but I have a question: is there any possibility to convert soil colors with chroma = 1 (ie 10YR 5/1) to RGB?


Hi Rosca,

This has been a long-standing problem, as the conversion table I have been using only includes chroma values down to 2. I just updated the aqp package on R-Forge, with a newly derived look-up table that includes chroma values down to 1. The updated version will be on CRAN within a week. Here is an example:

# simulated data from color book
d <- expand.grid(hue='10YR', value=2:8, chroma=1:8)
d$color <- with(d, munsell2rgb(hue, value, chroma))
# similar to the 10YR color book page
plot(value ~ chroma, data=d, col=d$color, pch=15, cex=3, axes=FALSE, main='10YR')
axis(1, tick=FALSE)
axis(2, tick=FALSE, las=2)

Updated Munsell Conversion ExampleUpdated Munsell Conversion Example