Publications by Marc in the box

R functions for Earth geographic coordinate calculations

29.05.2011

Here are some functions that I regularly use for geographic data (e.g. binning, filtering, calculation of new positions etc.).#distance in kilometers between two long/lat positions (from "fossil" package) earth.dist <- function (long1, lat1, long2, lat2) { rad <- pi/180 a1 <- lat1 * rad a2 <- long1 * rad b1 <- lat2 * rad b2 <...

518 sym R (1737 sym/4 pcs) 2 img

Array position to matrix coordinates conversion

30.05.2011

#A function that is sometimes useful in determining the #coordinate(i.e. row and column number) of a matrix position #(and vice-versa). #Either a vector of positions ("pos") #OR a 2 column matrix of matrix coordinates, ("coord", i.e. cbind(row,col)), #AND the matrix dimentions must be supplied (dim.mat, i.e. c(nrow,ncol)). pos2coord<-function...

392 sym R (836 sym/1 pcs) 2 img

map.xyz(): interpolation of XYZ data and projection onto a map

30.05.2011

     I am still struggling to get a grasp of R's mapping capabilities. Part of my frustration lies in the fact that I often work on areas near the poles, which complicates interpolation across the 180 degree line. For smaller areas, interpolation can be done using the interp() function in the package akima. I have taken the result...

991 sym 4 img

Simulating CMYK mis-registration printing

03.06.2011

I recently came across a poster advertising a children's production of Shakespeare's The Tempest where they purposely used an effect to mimic a mis-registration in CMYK printing. You have probably seen this before as a slight offset in one of the 4 colors (cyan, magenta, yellow, and black).     The CMYK color model is “subtracti...

1693 sym 4 img

Image color palette replacement

09.06.2011

Here is an example of a function I wrote to change the color palette used in an image. The above example comes from a black and white original, although color images can also be used. The function first converts the image to grayscale in order to have levels of color intensity between 0-255. Using a new color palette with 256 color levels, the gr...

948 sym 4 img

Clarke and Ainsworth’s BIOENV and BVSTEP (and BIO-BIO etc…)

30.06.2011

Nonmetric Multidimensional Scaling (NMDS) plot of vegetation sample dissimilarities with best correlating environmental variables (left) and species (right) plotted as vectors (datasets “varespec” and “varechem” from the package vegan) The R package “vegan” contains a version of Clarke and Ainsworth's (1993) BIOENV analysis allowi...

1882 sym 4 img 1 tbl

Color reduction of an image – and Warholize?

05.07.2011

There seems to be several methods out there for reducing the colors in an image. I became interested in this after pondering how this is done in the excellent freeware program IrfanView. Unfortunately, their method is not described anywhere that I could find, but I imagine that it is something along the tree data structure collapse method that Im...

1175 sym 4 img

Creating svg graphics for web publishing

25.07.2011

&lt;p&gt;&amp;amp;amp;amp;amp;lt;p&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;amp;amp;amp;amp;lt;p&amp;amp;amp;amp;amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;lt;p&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;lt;p&amp;amp;amp;am...

3216 sym

Adding a scale to an image plot

31.08.2011

Here's a function that allows you to add a color scale legend to an image plot (or probably any plot needing a z-level scale). I found myself having to program this over and over again, and just decided to make a plotting function for future use. While I really like the look of levelplot(), the modular aspect of image() makes it much more handy t...

1128 sym 2 img

Converting values to color levels

12.09.2011

     Adding color to a plot is helpful in many situations for visualizing an additional dimension of the data. Again, I wrote the below function “val2col” in R after having coded this manually over and over in the past. It uses similar arguments as the image function in that one defines the colors to be used as well as optional break poin...

1480 sym 2 img