Since QGIS 2.0 stable was released just a while ago, i thought that it would be time to enhance my plugin LecoS a bit more. Furthermore i also missed some functions, for instance i found no appropriate function to compute ZonalStatistics for a set of rasters of mine. SAGA has a function to calculate some stats using a categorical and a zone raster layer. However it is lacking a raster output and specific stats. So i added a new ZonalStatistics function to LecoS and i am sure that it will be of some use to Landscape ecologists and other GIS users out there. See a usecase below!
Furthermore i regularly use a lot of short python scripts to generate and query raster layers using a gdal+numpy backbone. Those custom functions of mine are a lot faster than any other plugin (all hail to numpy), which is why i also implemented some functions that are already available in QGIS through other plugins.
Here is the total changelog from the last LecoS version 1.8.2 to the new 1.9 (note that QGIS 1.8 won’t be supported anymore):
# Version 1.9 ### Major Update: ### - Added new tools to the Processing toolbox for use in complex models - Function to count Raster cells -> Output as table - Function to query raster values below a point layer - Function to intersect two landscape (raster) layers -> Output clipped raster - Function to creates a new random raster based on values from a statistical distribution -> Output raster - Function to conduct a Neighborhood analysis (analogous to r.neighbors. or Focal Statistics in ArcGis) - Function to conduct a connected component labeling of connected patches - Function to conduct ZonalStatistics based on two landscapes (ZonalStatistics with raster layers in ArcGIS) - Improved the overall documentation for the Processing Toolbox and created new simple icons - Fixed Bug: http://hub.qgis.org/issues/8810
I didn’t create any new graphical interfaces as i believe that sextante aka processing is the future. All new functions were therefore only added to the processing toolbox and not as seperate GUI. This also has the cool advantage that you could use all LecoS tools within more complex multi-algorithms models. The most visible difference to older LecoS versions is that i created a new icon for every function (make them distinguishable) and wrote documentary information.
Click more to see a short tutorial demonstrating the functions using real data.
R has grown a lot in the past years and is increasingly used as GIS. For many spatial operations and even spatial statistics certain R packages are simply the best choice up to date. For instance Home-range analysis are kinda impossible to perform (at least for me) without looking at the adehabitat packages. You want to perform a spatial operation in a script and do not know how to code python: Just use R. Francisco Rodriguez-Sanchez has posted very nice examples how to perform GIS tasks completely within R.
However R as GIS lacks the simplicity in matters of design and it requires quite an effort to make a good-looking map. Therefore using QGIS for map-design and output is always the favored choice for me. But why use R and QGIS independently? Through the SEXTANTE Toolbox for QGIS it is possible to execute fast and precise r-scripts for your spatial data just in QGIS.
What you need to do:
- Download the current QGIS dev. and R.
- Enable SEXTANTE in QGIS and activate the R-scripts in the SEXTANTE options provider window. Furthermore specify a R-scripts folder where you store your scripts.
- Also make sure that your scripts are logged (it is in the SEXTANTE options as well)
- Execute one of the Example R-scripts to test if the scripts are working.
If the above steps all turned out as expected you could start formatting your own r-scripts into a so-called .rsx file (R SEXTANTE script).
Here is a little info-graphic how to use R in a SEXTANTE context:
So open your favorite text-editor (or the new r-script dialog in QGIS) and create a new file. Save it into the rscripts folder inside your QGIS profile directory (“~/.qgis2/sextante/rscripts” on Linux based systems. Similar structure under Windows inside of your Documents folder). All .rsx scripts start with defining a group (where to save the script in SEXTANTE) and continue with additional inputs specified by the user. All Input data comes with two hashs in front. Furthermore you need to specify if the script output should show plots (add “#showplots” at the beginning of the script) and/or console output (start a command with “>”).
After you wrote your script, startup QGIS, open the SEXTANTE toolbox and have fun executing it. All things are possible, but it isn’t really easy to debug .rsx scripts in QGIS as the output is limited and sometimes you just wonder why it isn’t working.
To get you started here is the basic script to do the nice-looking levelplot from the rasterVis r-package:
##[Own Scripts] = group ##layer = raster ##showplots library(rasterVis) myPal <- terrain.colors(20) levelplot(layer,col.regions=myPal,contour=T)
Script is stored in the “Own Scripts” group. It just requires a raster (best is a DEM) as input.
You could extend the scripts by saving the output to a user defined folder or by creating just a plot for a specific extent (for instance the current QGIS extent). Output looks like this for the country of Skane in south Sweden:
just a quick update as i am really busy with studying right now. I just added SEXTANTE support to LecoS and although it isn’t as powerful as the original LecoS Gui (only allows you to calculate a single metric at once) you can now address most of the functions (vector analysis excluded) from within the SEXTANTE toolbox. Simply enable it in the options first to see it in the toolbox.
What is it good for?
Well, you can now batch-process the LecoS functions for multiple rasters and also include the landscape analysis tools in the SEXTANTE modeller. Below is a simple example of a model i just created. It takes a raster (Satellite landcover image) and a polygon (Training Data) as input and then automatically performs a maximum likelihood supervised classification. Afterwards it uses the landscape modifier function “Clean small pixels” to clean up the result and then calculates the total sum of all newly classified landscape pixels with the landscape analysis tool.
I think this is it for now with new features for LecoS. Unless me or someone else needs a new fancy technique, i will make a feature freeze for now. Please report any bugs and blockers on the bugtracker. Maybe i can mark the whole plugin as stable as soon as QGIS 2.0 will be released.