One of the most difficult elements of multivariate analysis is visualising the results. Good clear figures are essential in order to communicate results to an audience.
Non metric multidimensional scaling (NMDS) aims to reduce the dimensionality of a difference matrix. Visualising a reduction to two dimensions is easy enough. However the stress of the ordination is often greatly reduced (i.e the original rank distances are reproduced more accurately) when three or more axes are used. This is particularly true for large data sets that include many environmental gradients. So it has now become a very common practice to take advantage of the fact that RGB colours can be combined to represent three dimensions visually.
The results of an NMDS are a three column data frame with one column representing each colour. When blended together the differences shown in three dimensions can be represented in two dimensions (a map) or in one dimension (leaves on a tree).
This is particularly useful for mapping. However moving the results into a GIS needs a little work.
If the NMDS layers are represented as rasters the issue of displaying the results is trivial, as all GIS software is already setup to display a three layered rgb raster.
However displaying the results for polygons (or vectorised raster layers) is not quite as straitforward.
There are some solutions posted online. However non of the suggestions that I found achieved exactly what I wanted. I have tried parsing XML previously in R. It is generally something of a nightmare. So I went for a quick and dirty solution. If you open a prebuilt Quantum GIS QML sheet in a text editor and find and replace all commas by escaped commas \” it is then possible to paste the text strait into an R script and break it into parts. Then just add in the variables using cat. The step of replacing commas is essential in order to avoid the quotation marks breaking up the text.
The code as a function is available from GitHub. The function should work for any three column data frame with rownames that coincide with an attribute column in a shapefile(possibly needing some minor tweaking).
Clearly not at an elegant solution! However it worked perfectly in my case and produced exactly what I wanted. It is also fairly easy to adapt, providing that you look carefully at the way a QGIS style sheet is arranged.
This was the result when applied to a Biotic regionalisation analysis that I am trying to find time to tidy up. First for polygons.
Then for a graticule of 0.2 degrees. The NMDS uses results from SDMS in order to ensure that all cells have enough species. There is some similarity to GDM, but this is an model first, assemble later technique.
The block of pure blue in the North of Mexico is an artefact of insufficient sampling. I just need to set a default color to transparent to get rid of it. However the results as a whole are quite encouraging.