As I can see my QGIS plugin LecoS is still widely used and downloaded from the QGIS plugin hub. I have noticed that some people already started referencing ether my blog or the QGIS repository in their outputs, which is fine, but after thinking about it for a while I thought why not make a little descriptive article out of it (being an upstart PhD scholar and scientist an’ all). I am now happy to announce that this article has passed scientific peer-review and is now been published in early view in the Journal of Ecological Informatics.
LecoS — A python plugin for automated landscape ecology analysis
The quantification of landscape structures from remote-sensing products is an important part of many analyses in landscape ecology studies. This paper introduces a new free and open-source tool for conducting landscape ecology analysis. LecoS is able to compute a variety of basic and advanced landscape metrics in an automatized way. The calculation can furthermore be partitioned by iterating through an optional provided polygon layer. The new tool is integrated into the QGIS processing framework and can thus be used as a stand-alone tool or within bigger complex models. For illustration a potential case-study is presented, which tries to quantify pollinator responses on landscape derived metrics at various scales.
The following link provided by Elsevier is still active until the 23 of January 2016. If you need a copy later on and don’t have access to the journal (sorry, I didn’t have the money to pay for open-access fees), then feel free to ether contact me or you can read an earlier prePrint of the manuscript on PeerJ.
So if you are using LecoS in any way for your work, it would be nice if you could reference it using the citation below. That shows me that people are actively using it and gives me incentives to keep on developing it in the future.
Martin Jung, LecoS — A python plugin for automated landscape ecology analysis, Ecological Informatics, Volume 31, January 2016, Pages 18-21, ISSN 1574-9541, http://dx.doi.org/10.1016/j.ecoinf.2015.11.006.
The full sourcecode of LecoS is released on github.
There are many interesting things to calculate in relation to landscape ecology and its statistical metrics. However many (if not the majority) of the published toolsets are not reproducible, their algorithm code not published or open-source. Obviously this makes the easy implementation of underlying algorithms even harder for independent developers (scientists) if you don’t have the time to reproduce their work (not to mention the danger of making stupid mistakes, we are all human).
I recently found this new article in Methods in Ecology and Evolution by Etherington et al., who didn’t really present any novel techniques or methods, but instead provided a new python library that is capable of calculating Neutral Landscape Models (NLMs). NLMs are often used as nullmodel counterpart to real remote-sensing derived maps (land-cover or altitude) to test the effect of landscape structure or heterogeneity on a species (-community). Many NLM algorithms are based on cluster techniques, cellular automata or calculating randomly distributed numbers in a given 2d space. There have been critical and considerate voices stating that existing NLMS are often misused and better null-models are needed for specific hypothesis, such as a species perception of landscape structures. Nevertheless NLMs are still actively used and new papers published with it.
The new library, called NLMpy, is open source and published under the MIT licence. Thus I can easily use and integrate into QGIS and its processing framework. Their NLMpy library only depends on numpy and scipy and thus doesn’t add any other dependency to your python setup, if you already are able to run LecoS in your QGIS installation. The NLM functions are visible in the new LecoS 1.9.6 version, but only if you have NLMpy installed and it is available in your python path. Otherwise they won’t show up! Please don’t ask me here how to install additional python libraries on your machine, but rather consult google or some of the Q&A sites. I installed it following the instructions on this page.
After you have installed it and upgraded your LecoS version within QGIS, you should be able to spot a new processing group and a number of new algorithms. Here are some screenshots that show the new algorithms and two NLMs that I calculated. The first one is based on a Midpoint displacement algorithm and could be for instance used to test against an altitude raster layer (need to reclassify to real altitude values first). The second one is aimed at emulating a random classified land-cover map. Here I first calculated a proportional NLM using a random cluster nearest-neighbour algorithm. Second I used the libraries reclassify function (“Classify proportional Raster”) to convert the proportional values (range 0-1) into a relative number of landcover classes with exactly 6 different land-cover classes. Both null model look rather realistic, don’t they 😉
This is a quick and dirty implementation, so there could occur some errors. You should use a meter-based projection as extent (such as UTM) as negative values (common in degree-based projections like WGS84 latitude-longitude) sometimes result in strange error messages. You also have to change the CRS of the generated result to the one of your project manually, otherwise you likely won’t see the result. Instead of the number of rows and columns as in the original implementation, the functions in LecoS are based on a selected extent and the desired output cellsize.
For more complex modelling tasks I would suggest that you use the library directly. To give you a good start Etherington et al. also appended some example code and data in their article´s supporting information. Furthermore a few days ago they even had a spatial MEE blog post with some youtube video demonstrations how to use their library. So it shouldn’t be that hard even for python beginners. Or you could just use the processing interface within LecoS.
In any way, if you use the library in your research, I guess the authors would really appreciate it if you could cite them 🙂
- Etherington, T. R., Holland, E. P., O’Sullivan, D. (2014), NLMpy: a python software package for the creation of neutral landscape models within a general numerical framework. Methods in Ecology and Evolution. doi: 10.1111/2041-210X.12308
In addition I also temporarily removed LecoS ability to calculate the mean patch distance metric due to some unknown errors in the calculation. I’m kinda stuck here and anyone who can spot the (maybe obvious) bug gets a virtual hug from me!
Happy new year!
This is just a quick posting informing all the QGIS interested readers of this blog that I am about to release a new QGIS plugin. It’s name is QSDM (QGIS Species Distribution Modelling) and similar as with LecoS it is particular suited for the practicing ecologists out there. This time i had no plan and interest of coding a graphical interface and thus the whole plugin can only be executed from within the Processing Toolbox (QGIS version > 2.0 ). In my opinion this will be the future of most advanced QGIS plugins anyway.
So what is the idea? Basically QSDM is a plugin taking statistical models for species distribution modeling to QGIS. For now only the famous Maxent is enabled and working, but the ambitious plan is to enable other modeling techniques such as RandomForests and LogisticRegression as well if the user has the necessary libraries enabled.
You might ask what is the advantage of running Maxent from within QGIS? First, you can immediately see the output so it is nice for visual exploration. Second, the QSDM plugin helps you with the formating of your layers and occurrence files. For instance all input raster layers are automatically unified to a common resolution and exported as ESRI .asc files. You simply need to load in your layers and let the tool do the rest. For those of you who want more control (and I really insist that you want to), I also enabled functions to generate a custom parameter file for Maxent and enabled an option to start the Maxent GUI in a new process.
–> I recognize that the easiness of this tool might tempt more people to execute tools without really understanding what they do and how they work. Please be sure what you do and always (!!!) validate the outputs of the tools you use (this includes QSDM). For understanding Maxent parameters I highly recommend reading the attached literature list and this publication!
Other things i implemented in the initial release of QSDM
- Create Species Richness grid
- Creates a new raster containing Species Richness or Endemism of input occurence layer
- Calculate Niche Overlap Statistics
- Can calculate Schoener’s D or Warren’s I based on Hellinger distances for all input layers.
- Range Shift
- Shows the difference between two input prediction layers. For instance for current and likely future conditions.
- Data Transformations
- Makes quick transformations of input raster layers
More is planned, but this depends entirely on my inclination to do so, the time I have available and if it can be useful for my own research as well.
Please remember that the plugin is still experimental. So please don’t be angry if it doesn’t work for you. testing was conducted on QGIS 2.2 stable on my Debian Linux machine and it should hopefully work for Windows as well. But similar as with LecoS i have no opportunity to test the plugin on Mac OS based systems and I also don’t really intend to :-p. Sorry Apple.
- Steven J. Phillips, Robert P. Anderson and Robert E. Schapire, (2006) “Maximum entropy modeling of species geographic distributions” Ecological Modelling, Vol 190/3-4 pp 231-259
- Steven J. Phillips and Miroslav Dudik, (2008) “Modeling of species distributions with Maxent: new extensions and a comprehensive evaluation.” Ecography, Vol 31, pp 161-175
- Jane Elith et al. (2011) “A statistical explanation of MaxEnt for ecologists” Diversity and Distributions, 17, 43–57 DOI: 10.1111/j.1472-4642.2010.00725.x
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.
And another short update:
Due to recent API-changes my QGIS plugin LecoS was not running anymore under current development versions of QGIS. To make the plugin ready for the upcoming release of QGIS 2.0, i separated the development between a stable version and a development version. The stable version (v. 1.7.5) runs only with QGIS 1.8 Lisboa, while the current development version (v. 1.8) is only supported by QGIS master and the upcoming QGIS 2.0 release.
Get them here or via the Plugin downloader.
In the future i will most likely only extend the development version as the QGIS 2.0 is to be expected soon this year.
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.
i just pushed another update to my Landcover analysis plugin LecoS. Besides fixing various bugs for Linux and Windows it now contains a remodeled BatchOverlay-Tool (the tool which allows you to compute statistics for overlaying vector grids on raster layers). It is now capable of calculating multiple metrics landscape wide and per class. The output can be displayed directly on the screen, saved in a temporary/given file or in the vector tables attribute table (Enabled in ver. 1.7.1)
I tested the Plugin under Linux (Debian Testing) and Windows (XP SP3). On both System the plugin should at least be able to start and calculate some metrics. However remember that this plugin is still marked as experimental and therefore bugs and strange python error messages might occur.
There is a known bug under Windows, when trying to add a generated table to the QGIS table of contents. If you try to this on Windows systems it will crash QGIS 1.8 and results in an Error message for QGIS dev. –> Fixed in recent update 1.7.1
Changelog for current Version 1.7.2:
– Enabled the calculation of landscape statistics for vector layers
– Replaced QMessageBoxes with QMessageBar messages if a newer QGIS version (>= 10900) is used
– Removed the landscape diversity tool and merged options to calculate landscape diversity into the other toolset
– Bug fixing
- The plugin needs the python libraries scipy, numpy and pil (imaging) to run. If you don’t install them (default is “no” on Windows), than you’ll likely see error messages after startup. To install the libraries on Linux systems, just download them with your package manager (python-scipy, python-imaging) or compile them system wide. To install them on Windows download the OSGEO4W Installer , select advanced Install, search for the libraries python-numpy, python-scipy and python-imaging and check them all (besides checking the qgis binaries). If you do this correctly LecoS should run out of the box
- If you stumble upon any errors PLEASE don’t report them in this blog as i really lose track of those comments. Use the official bug-tracker to report any bugs while using LecoS and try to give me as much information about your system and QGIS setup (including package versions and maybe a small data subset for testing).
The development of this plugin has been supported by the University of Évora and future version will include the options to analyse landscape vector layers, additional metrics and post-hoc result grouping.