dylan's blog

InfoChimps

Submitted by dylan on Mon, 2010-03-08 00:30.


This looks interesting: http://infochimps.org/search?query=soil

Accessing Climate Change Data and a Custom Panel Function for Filled Polygons

Submitted by dylan on Fri, 2010-03-05 02:21.

GCS Model Grids

Recently finished some collaborative work with Vishal, related to visualizing climate change data for the SEI. This project was funded in part by the California Energy Commission, with additional technical support from the Google Earth Team. One of the final products was an interactive, multi-scale Google Earth application, based on PostGIS, PHP, and R. Interaction with the KMZ application results in several presentations of climate projections, fire risk projections, urban population growth projections, and other related information. Charts are dynamically generated from the PostGIS database, and returned to the web browser. In addition, an HTTP-based interface makes it simple to download CSV-formatted data directly from the CEC server. Some of our R code seemed like a good candidate for sharing, so I have posted a complete example below-- illustrating how to access climate projection data from the CEC server, a couple custom functions for fancy lattice graphics, and more.

Yet Another plyr Example

Submitted by dylan on Thu, 2010-03-04 18:22.

another plyr exampleanother plyr example quantiles (0.05, 0.25, 0.5, 0.75, 0.95) of DSC by temperature bin

There are plenty of good examples on how to use functions from the plyr package. Here is one more, demonstrating how to use ddply with a custom function. Note that there are two places where the example function may blow up if you pass in poorly formatted or strange data: calls to 1) t.test() and 2) quantile(). Also note the use of the transpose function, t(), for converting column-wise data into row-wise data-- suitable for inclusion into a dataframe containing a single row.

( categories: )

SoilWeb iPhone App: Beta-Testers?

Submitted by dylan on Wed, 2010-02-24 01:20.

iPhone App Screenshot rev 0.2 - iconiPhone App Screenshot rev 0.2 - icon

iphone App Screenshot rev 0.2 - in Fresnoiphone App Screenshot rev 0.2 - in Fresno

 
More Updates:
The application is now available on the Apple iTunes Store. Preliminary documentaion here.







Numerical Integration/Differentiation in R: FTIR Spectra

Submitted by dylan on Tue, 2010-02-23 21:42.

 
Stumbled upon an excellent example of how to perform numerical integration in R. Below is an example of piece-wise linear and spline fits to FTIR data, and the resulting computed area under the curve. With a high density of points, it seems like the linear approximation is most efficient and sufficiently accurate. With very large sequences, it may be necessary to adjust the value passed to the subdivisions argument of integrate(). Strangely, larger values seem to solve problems encountered with large datasets...

FTIR Spectra IntegrationFTIR Spectra Integration

Visual Interpretation of Principal Coordinates (of) Neighbor Matrices (PCNM)

Submitted by dylan on Sun, 2010-02-21 20:46.

Principal Coordinates (of) Neighbor Matrices (PCNM) is an interesting algorithm, developed by P. Borcard and P. Legendre at the University of Montreal, for the multi-scale analysis of spatial structure. This algorithm is typically applied to a distance matrix, computed from the coordinates where some environmental data were collected. The resulting "PCNM vectors" are commonly used to describe variable degrees of possible spatial structure and its contribution to variability in other measured parameters (soil properties, species distribution, etc.)-- essentially a spectral decomposition spatial connectivity. This algorithm has been recently updated by and released as part of the PCNM package for R. Several other implementations of the algorithm exist, however this seems to be the most up-to-date.

 
Related Presentations and Papers on PCNM

  • http://biol09.biol.umontreal.ca/ESA_SS/Borcard_&_PL_talk.pdf
  • Borcard, D. and Legendre, P. 2002. All-scale spatial analysis of ecological data by means of principal coordinates of neighbour matrices. Ecological Modelling 153: 51-68.
  • Borcard, D., P. Legendre, Avois-Jacquet, C. & Tuomisto, H. 2004. Dissecting the spatial structures of ecologial data at all scales. Ecology 85(7): 1826-1832.

Updates to SoilWeb

Submitted by dylan on Mon, 2010-01-18 04:19.

Soil Profiles in ColorSoil Profiles in Color

Added color support to the mini-profiles used in graphical map unit summaries, the Google Earth interface, and iPhone application. SSURGO doesn't contain soil color data, so colors (in Munsell notation) were extracted from the OSD database, and converted into RGB triplets. Using horizon information from the OSD database also results in much more realistic horizonation, as compared to what is stored in older SSURGO databases. Example of the Yolo series soil, from the Yolo County (1972) soil survey:

vs.

Interesting use of levelplot() for time series data

Submitted by dylan on Sat, 2010-01-16 18:58.

levelplot example: soil moisture and temperaturelevelplot example: soil temperature (left) and moisture (right)

Several recent articles appeared on the R-bloggers feed aggregator that demonstrated an interesting visualization of time series data using color. This style of visualization was readily adapted for the time series data I regularly collect (soil moisture and temperature), and quickly implemented with the levelplot() function from the lattice package. I hadn't previously considered using a mixture of factor (categorical) and continuous variables within a call to levelplot(), however the resulting figure was more useful than expected (see above). A single day's observation is represented by a colored strip (redder hues are higher temperature values, and lower soil moisture values), placed along the x-axis according to the date of that observation, and in a row defined by the location where that observation was collected from. Paneling of the data can be used to represent a more complex hierarchy, such as sensor depth or landscape position. At the expense of quantitative data retrieval (which is better supported be scatter plots), qualitative patterns are quickly identified within the new graphic.

Estimated Net Worth of SoilWeb- Our Online Soil Survey

Submitted by dylan on Mon, 2009-12-28 21:08.

According to the excellent source code evaluation tool, SLOCCount, our online soil survey (SoilWeb) code is worth about $268,543 and would require about 2 years of development time to re-create from scratch with a single developer working full-time. This is a fairly close estimate, as I have been working (part-time) on this code-base for 3 years now with most of the time spent in the first 2 years. For comparison, the current development version of GRASS 6 is based on about 230 person-years of development time and is worth about 31 million dollars. Neat!

 
SLOCCount Output

Total Physical Source Lines of Code (SLOC)                = 8,910
Development Effort Estimate, Person-Years (Person-Months) = 1.99 (23.86)
 (Basic COCOMO model, Person-Months = 2.4 * (KSLOC**1.05))
Schedule Estimate, Years (Months)                         = 0.70 (8.34)
 (Basic COCOMO model, Months = 2.5 * (person-months**0.38))
Estimated Average Number of Developers (Effort/Schedule)  = 2.86
Total Estimated Cost to Develop                           = $ 268,543
 (average salary = $56,286/year, overhead = 2.40).
SLOCCount, Copyright (C) 2001-2004 David A. Wheeler

Un-Wrapping a Sphere with R

Submitted by dylan on Tue, 2009-12-08 19:48.

 
Premise
I was recently asked to print out a fabric pattern that could be used to cover a sphere, about the size of a ping pong ball, for the purposes of re-creating a favorite cat toy (quite important). Thinking this over, I realized that this was basically a map projection problem-- and could probably be solved by scaling an interrupted sinusoidal projection to match the geometry of a ping pong ball. Below are some R functions, and examples of how this endeavor evolved. Thanks to Greg Snow for this helpful post on the R-mailing list, describing how to preserve linear measurement when composing a figure in R. So far the pattern doesn't quite fit.

 
Update
It looks like it was not the printer's fault-- I had used the wrong radius for a ping pong ball: 16mm instead of 19mm or 20mm (there are 38mm and 40mm diameter ping pong balls). Updated files are attached.

Sinusoidal ProjectionSinusoidal Projection