LecoS – Land cover statistics is a plugin for the QGIS GIS software suite. LecoS originally stands for Landscape ecology statistics, but it can do a lot more than that.  It converts classified raster layers to arrays using the powerful numpy library. Based on a Connected Component Labeling approach it further identifies class patches and calculates landscape metrics. The user can choose to calculate single or several metrics for the raster classes. Recent versions of LecoS also include a polygon-overlay (BatchOverlay) tool, which allows the calculation of landscape metrics per polygon feature. I also created the Landscape Modifier, a nifty tool to extract edges, increase or decrease or close holes in raster-patches. Since version 1.9 most LecoS functions are available within the QGIS processing framework.


LecoS is released under a general GPL license v3 and is free of charge for everyone. But please notice that this piece of software is under development and the author takes no responsibility for bugs or miscalculations. So please verify any results independently or with a common sense.

Example use case:

-> Download the current CORINE 2006 dataset (and the provided qgis colourmap) and load them into QGIS.

Loaded Corine dataset with correct classification

-> Crop to an area of interest. In my case i quickly draw a polygon over the city of Marburg, Germany and croped the landcover raster via the gdalwarp utility using the polygon as mask layer. The CORINE nodata value is -999.  See the result below.

Croped area of interest from the CORINE dataset

-> Now open the LecoS Land cover statistic gui via the menu (Raster/Landscape Ecology/Land cover statistics). Choose the new croped raster layer and check if the cellsize is correct (CORINE has a spatial resolution of 100m per cell). You can choose “Direct value output” just for information (in a small dialog) or save the results in a csv file for further processing.
As for me i want to save the results and calculate the following metrics from the “Select multiple Metrics” tab:

LecoS GUI. Calculating several metrics with csv output

-> Now run the program and import the results in a spreadsheet software of your choice (Excel, Libreoffice).

Results in libreoffice

The class values represent the grid values in your raster layer, while the other columns are the metrics you calculated. You can lookup the class values in the clc2006 legend table. As you can see in my example class number 12 (Non-irrigated arable land) is the most abundant land cover in the vicinity of Marburg. It makes up nearly 38 % of all cover types and is represented by 28 unique patches in the croped raster layer.

Example use case for the PolygonOverlay tool -> Here and here (updated Gui)

Example use case for the Landscape Modifier -> Here

Another example use case can be seen in this prePrint article about LecoS.


You can find the plugin via the QGIS-Plugin downloader. The plugin is also downloadable from the QGIS plugin hub. Usage requires python and the libraries numpy, scipy and PIL installed (See Install).


Before you install make sure that scipy, numpy and pil are installed! Otherwise the plugin won’t work!

Install via the QGIS Plugin Downloader or manual. Manual means that you download the Archiv and extract the folder to the QGIS Plugin dir (~/.qgis/python/plugins/ on Linux machines and (qgis_install folder)/python/plugins on Windows). In both cases you need to have the scientific libraries numpy and scipy installed!

If you did not consciously 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-numpy, python-pil) or compile them system wide.  They have to be available inside your QGIS python environment.
  • 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). Here is quick and dirty tutorial how to install LecoS on Windows XP using the OSGEO4W installer: 24072013_HowToInstallScipyForQGis.pdf . It was written for QGIS 1.8, but should still work with newer QGIS versions.
  • On MacOS you need to install the custom KyngChaos QGIS version including its python bindings. Numpy, Scipy and PIL can be found on the KyngChaos site as well and i advice user to follow the install intructions.

LecoS was tested under Linux Debian (Wheezy testing) and Windows XP (SP 3). If the necessary libraries are installed it should run out of the box for both QGIS 1.8 stable (Lisboa), QGIS 2.0 (Dufour) and QGIS dev. (Master).

Errors and Bugs:

If you stumble upon any errors PLEASE don’t report them in this blog as I really lose track of all 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).

Please acknowledge that I can not rule out errors in the code and I programme this tool in my free time. If in doubt about any metric (and you should always crosscheck), please check the code repository for the underlying source code.


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.

Current version: 1.9.8

I will continuously adapt  and improve the QGIS-plugin in the future, if I have the time for it. Please reply below this post, if you have any ideas of improvement. Specific wishes can be implemented against a little donation.

See my blog posts below for more infos about the new versions

The development of recent versions of this plugin has been supported by the Universidade de Évora, Departamento de Biologia, Unidade de Biologia da Conservaçao.

129 responses to “LecoS”

  1. Paolo Cavallini says :

    Please have a look to r.li module in GRASS. Moving window metrics are especially useful IMHO.
    Thanks a lot!

  2. Paolo Cavallini says :

    Also, please consider adding it as a SEXTANTE plugin or module: it will be very useful to use in in more complex modelling.
    Thanks again.

  3. Paolo Cavallini says :

    You can have a look to the plugin SEXTANTE example provider, it should be clear enough. I warmly invite you however to discuss this on the qgis-dev mailing list, as other people will be interested, and could collaborate.

  4. paul says :

    Great work! Some isolation metrices would be also very useful.

    • Curlew says :

      Indeed! I wanted to realize them but i couldn’t get the calculation of the patch perimeters (which is the basis of many indices) to work. Maybe later, when i have the time to code

  5. Anonymous says :

    Please add your plugin to the Raster menu and toolbar, rather than to the generic one(it will be easier to find it). Also, the info button is somewhat non-standard, please follow other plugins.
    Also, your paricipation to qgis-dev mailing list will make cooperation much easier than posting here.
    Thanks a lot!

    • Curlew says :

      Heyho, i think i added it to the raster menu, but it only appears there if you use a qgis version above 1.8. In my version (1.9 trunk ) it appears in the raster menu and toolbar. But i will change that as well as the info button. I will try to participate in the list. Hopefully i don’t get flooded by emails all over 🙂

  6. marc says :

    Please, could you write how to install the plugin without “plugin installer”?
    I do not how to do this.

  7. pcav says :

    You will get a lot of mail from qgis-dev, so I suggets you to filter it. Nevertheless, it is very worhtwhile. Dispersing information is no good.

  8. pcav says :

    You do not need to instal it by hand, use the repo.

  9. Filipe says :

    Hi, I tried to install LecoS on W7 64 bits and got a message saying that I need scipy. I looked for it in osgeo4w but didnt find it there. What should I do? Tks

    • Curlew says :

      i added that information to the install note in the text above. Basically you’ll need to install scipy/numpy (which are very useful python extension). to your python folder. You will find all necessary information on the numpy homepage (http://numpy.scipy.org/)

  10. Filipe says :

    H, thanks. Can you please point me the file that I need to download?. I only found installers that require me to have python 2.7 installed. The python that QGIS uses (and the only one I have) is in c:/osgeo

    • Curlew says :

      Uhh, that completely depends on your python version and system. I am only using linux (where python and numpy/scipy are installed and used system wide). I don’t know how to proceed with some custom install under windows. You should download the current archives from sourceforge (http://sourceforge.net/projects/numpy/files/ and http://sourceforge.net/projects/scipy/files/ ) and get your python (which qgis uses) to recognize these libraries. Maybe ask someone from the osgeo development team how to install additional libraries

      • Justine says :

        I have been desperately trying to install numpy and scipy so that lecos would work and have not yet been successful.
        I have downloaded Anaconda (http://www.scipy.org/install.html) to my Mac-OS Snow leopard. However my QGIS 2.0 still does not identify that I have downloaded scipy and Lecos still can not be installed.

        I realize I have to get python to recognize the scipy and numpy libraries but how do I do that?

        does anyone have suggestions?

        thankyou, really appreciate it.

        • Curlew says :

          I am really really sorry, but i can not help you with Macs. I have never owned one and i can’t even confirm myself how and that everything will work. I heard a lot of good things about the kyngchaos sources. Maybe you try them as well. http://www.kyngchaos.com/software/qgis
          Python normally already ships with QGIS so you don’t need to install it seperately

  11. Anonymous says :

    Sorry, I think it is rather pointless to discuss basic QGIS issues here. I would suggest to go to the main QGIS resources, especially the mailing list

  12. thomas says :

    with Qgis 1.8.0 in Windows, after followig the text above, I got this error:

    Couldn’t load plugin LecoS due an error when calling its classfactory()

    Traceback (most recent call last):
    File “C:/PROGRA~2/Quantum GIS Lisboa/apps/qgis/./python\qgis\utils.py”, line 164, in startPlugin
    plugins[packageName] = package.classFactory(iface)
    File “C:/PROGRA~2/Quantum GIS Lisboa/apps/qgis/./python/plugins\LecoS\__init__.py”, line 35, in classFactory
    from lecos_main import LecoS
    File “C:/PROGRA~2/Quantum GIS Lisboa/apps/qgis/./python\qgis\utils.py”, line 309, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
    File “C:/PROGRA~2/Quantum GIS Lisboa/apps/qgis/./python/plugins\LecoS\lecos_main.py”, line 29, in
    from lecos_dlg import LecosDialog
    File “C:/PROGRA~2/Quantum GIS Lisboa/apps/qgis/./python\qgis\utils.py”, line 309, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
    File “C:/PROGRA~2/Quantum GIS Lisboa/apps/qgis/./python/plugins\LecoS\lecos_dlg.py”, line 35, in
    import landscape_statistics as lcs
    File “C:/PROGRA~2/Quantum GIS Lisboa/apps/qgis/./python\qgis\utils.py”, line 309, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
    File “C:/PROGRA~2/Quantum GIS Lisboa/apps/qgis/./python/plugins\LecoS\landscape_statistics.py”, line 29, in
    import gdal, numpy, sys, scipy, string, math, ogr, os
    File “C:/PROGRA~2/Quantum GIS Lisboa/apps/qgis/./python\qgis\utils.py”, line 309, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
    ImportError: No module named scipy

    Versione Python:
    2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)]

    Versione di QGIS:
    1.8.0-Lisboa Lisboa, 6416f38

    What can I do?

  13. Anonymous says :

    Is there a bugtracker available for this? The plugin has to be fixed due to the API change.

    An error has occured while executing Python code:

    Traceback (most recent call last):
    File “/home/paolo/.qgis//python/plugins/LecoS/lecos_main.py”, line 108, in runBatch
    dlg = BatchDialog( self.iface )
    File “/home/paolo/.qgis//python/plugins/LecoS/lecos_dlg.py”, line 400, in __init__
    File “/home/paolo/.qgis//python/plugins/LecoS/lecos_dlg.py”, line 416, in startup
    ras = func.getRasterLayersNames()
    File “/home/paolo/.qgis//python/plugins/LecoS/lecos_functions.py”, line 133, in getRasterLayersNames
    if layer.type() == QgsMapLayer.RasterLayer and ( layer.usesProvider() and layer.providerKey() == ‘gdal’ ):
    AttributeError: ‘QgsRasterLayer’ object has no attribute ‘usesProvider’

  14. Anonymous says :

    Hello Curlew, this is Thomas. So can’t get your plugin to work – my python imaging library is 1.1.7-4. I’m using QGIS 1.8 in Linux Mint 13. Error report here: http://www.replicamag.co.uk/error_msg.txt

    • Curlew says :

      Thanks, for providing the data. mhh, the reason because it doesn’t work definitely has something to do with your vector shapes. If you make a test-polygon somewhere on your raster, the polygon overlay works (doesn’t appear in the attribute-table until reloading). I also resampled your raster (and set a no-data value) to make sure the error doesn’t come from the raster. I’ll suggest to somehow explode or simplify your polygons and try again. I’ll look into the reason for this error in the mean-time and report back as soon as i find something (will upload a fix to plugin downloader).

      I also got it to work with lecos. First you have to define the value zero as correct no-data value for your raster. Then use the “polygon parts to separate polygons” SAGA module in the Sextante toolbox or a similar tool to explode your polygon features into separate parts. Now you can slowly work through the parts of the features with lecos. However i advise you to use SAGA in the mean time. Maybe i can get a clue why lecos fails (i believe it has something to do with multiple hoverlapping inner and outer polygon rings).

  15. Anonymous says :

    Hi Curlew

    first, thanks a lot for the great work. I followed your descriptions, but receive the following error message when I try to open the Lecos menu. Any help would be really appreciated.



    • Anonymous says :

      sorry, here is the message

      Traceback (most recent call last):
      File “C:/PROGRA~1/Quantum GIS Lisboa/apps/qgis/./python/plugins\LecoS\lecos_dlg.py”, line 105, in setNoData
      TypeError: arguments did not match any overloaded call:
      QDoubleValidator(QObject parent=None): argument 1 has unexpected type ‘int’
      QDoubleValidator(float, float, int, QObject): not enough arguments

      2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)]

      1.8.0-Lisboa Lisboa, f440b60

      • Curlew says :

        Hej, this error appears, because you’ve quite a old version of QT shipping along with your QGis version. Can you make a screenshot of the first tab from the About windows (Menu -> About (Über)) and upload it to imgur ? I will to make a bugfix as soon as possible.

  16. pvanb says :

    Hi, the plugin is not working anymore in QGIS 1.9 (due to API change perhaps, also mentioned in another comment already). Error message is: ‘module’ object has not attribute ‘AllRegister’

    • Curlew says :

      Mhh, AllRegister is only mentioned once in every python-code in the beginning
      gdal.AllRegister() # register all gdal drivers
      The plugin itselfs works for me without any problems (QGis nightlybuild – Debian 64bit, Gdal-version 1.9.0). Maybe you’re using a newer gdal-version where this register-command isn’t necessary anymore

  17. szemanistvan says :

    When I installed the plugin I got the following message: “The gdal driver register command failed. LecoS might still work, but there is a chance of non working gdal file support.” When I click Ok, a new window appear with this python error message: “module object has no attribute UseExceptions” Have you ever met this problem? ps.: I’have used the LeCos with 1.8 QGIS and it worked perfectly. I wrote a user manual in hungarian also, but now the plugin doesn’t work. My OS: linux mint14, QGIS ver.: 1.9. Thank you in advance for your answer.

    • Curlew says :

      ahh, this was actually a fix for another user. I’ll try to look into it as soon as possible. For now you can simply comment this lines out (paste a #) before line 38 and 39 in the landscape.statistics.py file (look into your python folder ~/.qgis/python/plugins/LecoS )

      The Error obviously comes up because of recent changes in the GDAL library. I’m also using the Development Version as well, but GDAL-version 1.9.0
      I build a try-catch frame around this register-command, so download LecoS again (still has the same version number) and try it out.

      • szemanistvan says :

        Thank you for your quick reply. I tried your suggestions, and I got the following error message: “gdal.AllRegister() # register all gdal drivers
        AttributeError: ‘module’ object has no attribute ‘AllRegister'” I think I will reinstall the 1.8 version.

      • Haze says :

        I also have szemanistvan’s error…but on 1.8. Running QGIS 1.8 on Ubuntu 12.04 with python-gdal 1.9.2, I get “gdal.AllRegister() # register all gdal drivers AttributeError: ‘module’ object has no attribute ‘AllRegister'” as well.

  18. Manue says :

    I cannot find LecoS at the QGIS plugin installer (QGIS 1.8.0 for Windows)

    • Curlew says :

      It is an experimental plugin and comes without any warranty. You have to enable the option to allow experimental plugins to appear in the download list (Plugin-Downloader Options).

      • Manuel says :

        Thank you verym uch. I installed the plug-in but is asking me for scypy, which I installed but probably not in the right directory, How can I install scipy to run LecoS?

  19. Curlew says :

    Right now there is an error occurring within the QGis plugin upload server, so i can’t upload any new updates and i will just say the following:
    – All the errors related to GDAL don’t occur at my system. I am using gdal version 1.9.0. If your’re using something never than this you are probably are affected by some kind of recent API-change. Try to look into the error. It names the row and the file where the error happens. Go to the row and insert a “#” before the code (makes a comment). Or wait for the update certainly to be uploaded in the near feature (with some nice functions) and see if the error still occurs (in this case i need some professional advice).

  20. Tim says :

    Thanks for the great plugin! It took me a bit to get it running because of path issues. The problem I was having probably has a more elegant solution, but here is my work around that I thought I would pass along.

    Problem: I have a windows XP machine, with another copy/version of Python (2.7.3) on it at ‘C:\Python27’. The ‘site-package’ directory for this installation already has numpy and scipy and dependencies loaded and working well. When I recently loaded QGIS, it came with it’s own copy of Python (2.7.2), along with ‘site-packages’ that included numpy but not scipy. I tried to ‘install’ another copy of scipy in this new site-packages directory by unzipping the tarball there. Sometimes this seems to work for a module, but it didn’t work for this one. I guess I needed to run ‘python setup.py install’, but avoided it because I didn’t want to screw up my paths. I guess there may be additional options for installing it in a non-standard location, but I was too uncertain to do it. I avoided the scipy Windows installer, because it didn’t see the QGIS python installation and didn’t give me the option to install it under QGIS and I didn’t want to screw up my paths.

    Hack: So here is what I did. I went into the ‘C:\Program Files\Quantum GIS Lisboa\apps\Python27\Lib’ folder and found the site.py file. Right below the import statements, I found

    # Prefixes for site-packages; add additional prefixes like /usr/local here
    PREFIXES = [sys.prefix, sys.exec_prefix]

    and I changed it to read

    PREFIXES = [sys.prefix, sys.exec_prefix, ‘C:\\Python27\\Lib\\site-packages’]

    Now the QGIS python installation is able to find my original scipy module and it seems to be working fine. Presumably, other QGIS plugins will be able to take advantage of the many other modules I have installed in this directory, also.

    Hope this is useful for others. If anything, maybe it will prompt someone to describe a more elegant solution.


    • Curlew says :

      Great ! Thanks for testing. I always have issues with Windows systems because i don’t own one and therefore can’t do testing on it . On Linux the python path for QGIS is the same as for the system-wide install.

  21. gtsil says :

    first, thanks a lot for the great work.

    Get the following message when I try in LecoS 1.6.1, in Landcover Analysis to Save results as .csv

    > An error has occured while executing Python code:
    > Traceback (most recent call last):
    > File “/home/gtsil/.qgis//python/plugins/LecoS/lecos_dlg.py”, line 250, in accept
    > if path.exists(self.SaveCsv.text()):
    > NameError: global name ‘path’ is not defined
    > Python version:
    > 2.7.3 (default, Aug  1 2012, 05:27:35)
    > [GCC 4.6.3]
    > QGIS version:
    > 1.8.0-Lisboa Lisboa, exported
    > Python path: [‘/home/gtsil/.qgis//python/plugins/LecoS’, ‘/home/gtsil/.qgis//python/plugins/sextante_animove’, ‘/home/gtsil/.qgis//python/plugins/sextante_taudem’, ‘/home/gtsil/.qgis//python/plugins/sextante’, ‘/home/gtsil/.qgis//python/plugins/permaclim’, ‘/home/gtsil/.qgis//python/plugins/sextantelwgeomprovider’, ‘/home/gtsil/.qgis//python/plugins/sextanteexampleprovider’, ‘/usr/share/qgis/python’, ‘/home/gtsil/.qgis//python’, ‘/home/gtsil/.qgis//python/plugins’, ‘/usr/share/qgis/python/plugins’, ‘/usr/lib/python2.7’, ‘/usr/lib/python2.7/plat-linux2’, ‘/usr/lib/python2.7/lib-tk’, ‘/usr/lib/python2.7/lib-old’, ‘/usr/lib/python2.7/lib-dynload’, ‘/usr/local/lib/python2.7/dist-packages’, ‘/usr/lib/python2.7/dist-packages’, ‘/usr/lib/python2.7/dist-packages/PIL’, ‘/usr/lib/python2.7/dist-packages/gst-0.10’, ‘/usr/lib/python2.7/dist-packages/gtk-2.0’, ‘/usr/lib/pymodules/python2.7’, ‘/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode’, ‘/home/gtsil/.qgis/python/plugins/mmqgis/forms’,
    ‘/usr/share/qgis/python/plugins/fTools/tools’, ‘/home/gtsil/Desktop/Grassdata/Location_LandScape/MP_Typology/Project’]

    What can I do?

  22. Margareth says :

    I think this plugin will be very useful for many people. Congratulations! How we should cite this software? Maybe you should write a paper to one of the (landscape) ecological journals to promote this tool?

    • Curlew says :

      Hey, thanks that you appreciate my work 🙂 In fact i am considering of writing a little short communication as soon as the plugin reached a stable state (right now it is still experimental and bugs can occur).
      If you still wanna use it in a publication than you could use this provisional reference (can also be found in the about dialog):

      Martin Jung, 2012, LecoS – A QGIS plugin to conduct landscape ecology statistics, http://plugins.qgis.org/plugins/LecoS/

  23. Carlos Rios says :

    Hi, I have a Phyton error running in a clipped area of CORINE 2006 data set. Can you help me?
    I am on W7 64BITS

    Phyton Error:

    An error has occured while executing Python code:

    Traceback (most recent call last):
    File “C:/Users/GIS 02/.qgis//python/plugins\LecoS\lecos_dlg.py”, line 327, in accept
    name, result = cl_analys.execSingleMetric(m,cl)
    File “C:/Users/GIS 02/.qgis//python/plugins\LecoS\landscape_statistics.py”, line 196, in execSingleMetric
    return unicode(name), self.f_returnAvgShape(self.labeled_array,self.cl_array,self.numpatches)
    File “C:/Users/GIS 02/.qgis//python/plugins\LecoS\landscape_statistics.py”, line 385, in f_returnAvgShape
    feature = self.f_returnPatch(labeled_array,i)
    File “C:/Users/GIS 02/.qgis//python/plugins\LecoS\landscape_statistics.py”, line 238, in f_returnPatch
    feature = numpy.zeros_like(labeled_array, dtype=int)
    TypeError: zeros_like() got an unexpected keyword argument ‘dtype’

    Python version:
    2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)]

    QGIS version:
    1.8.0-Lisboa Lisboa, 6416f38

    Python path: [‘C:/Users/GIS 02/.qgis//python/plugins\\LecoS’, ‘C:/Users/GIS 02/.qgis//python/plugins\\sextante’, ‘C:/PROGRA~2/Quantum GIS Lisboa/apps/qgis/./python’, ‘C:/Users/GIS 02/.qgis//python’, ‘C:/Users/GIS 02/.qgis//python/plugins’, ‘C:/PROGRA~2/Quantum GIS Lisboa/apps/qgis/./python/plugins’, ‘C:\\Windows\\system32\\python27.zip’, ‘C:\\PROGRA~2\\Quantum GIS Lisboa\\apps\\Python27\\DLLs’, ‘C:\\PROGRA~2\\Quantum GIS Lisboa\\apps\\Python27\\lib’, ‘C:\\PROGRA~2\\Quantum GIS Lisboa\\apps\\Python27\\lib\\plat-win’, ‘C:\\PROGRA~2\\Quantum GIS Lisboa\\apps\\Python27\\lib\\lib-tk’, ‘C:\\PROGRA~2\\Quantum GIS Lisboa\\apps\\qgis\\bin’, ‘C:\\PROGRA~2\\Quantum GIS Lisboa\\apps\\Python27’, ‘C:\\PROGRA~2\\Quantum GIS Lisboa\\apps\\Python27\\lib\\site-packages’, ‘C:\\PROGRA~2\\Quantum GIS Lisboa\\apps\\Python27\\lib\\site-packages\\PIL’, ‘C:\\PROGRA~2\\Quantum GIS Lisboa\\apps\\Python27\\lib\\site-packages\\win32’, ‘C:\\PROGRA~2\\Quantum GIS Lisboa\\apps\\Python27\\lib\\site-packages\\win32\\lib’, ‘C:\\PROGRA~2\\Quantum GIS Lisboa\\apps\\Python27\\lib\\site-packages\\Pythonwin’, ‘C:\\PROGRA~2\\Quantum GIS Lisboa\\apps\\Python27\\lib\\site-packages\\wx-2.8-msw-unicode’, ‘C:\\PROGRA~2\\Quantum GIS Lisboa\\apps\\qgis\\python\\plugins\\fTools\\tools’]

    Best regards
    Carlos Ríos

    • Curlew says :

      Hi Carlos,
      please as i said in the page text: raise a bug-report for those errors in the future (http://hub.qgis.org/projects/lecos) as i really lose track of comments and other people might benefit more if they can search for a bug and see if other people had the same problem.

      Regarding your problem:
      The actual error (TypeError: zeros_like() got an unexpected keyword argument ‘dtype’) says that a provided parameter is not known to this numpy function. As this parameter certainly exists i advise you to update your numpy library. You can get the current version used in QGIS by typing (“import numpy” and “numpy.version.version”) into the python console. Mine is 1.6.2 and it definetly works here 🙂
      But please move future correspondence (if upgrading don’t solve your problem) to a bug-report on the official tracker.

  24. Ben Wells says :

    Hello. This plug-in would be perfect for our Wildlife Trust ecologist. However, when i followed your instructions for installing OSGEO4W Installer the installation resulted in an error message pop-up titled “Mount” stating Access is denied. Can you help at all?

  25. Christiaan says :

    Nice plugin to get more statistics than available in standard QGis. However, when applying the plugin to rasters with nodata values (I’m using the result of a inundation computation to assess the waterdepth on roads), the plugin gives an error:

    Traceback (most recent call last):
    File “../.qgis2/python/plugins\LecoS\lecos_dlg.py”, line 877, in go
    err, r = bat.go(cmd,None,cellsize,None,rasE)
    File “../.qgis2/python/plugins\LecoS\landscape_polygonoverlay.py”, line 179, in go
    r = self.returnArrayMax(array)
    File “../.qgis2/python/plugins\LecoS\landscape_polygonoverlay.py”, line 467, in returnArrayMax
    return numpy.max(array[array!=self.nodata])
    File “C:\OSGeo4W\apps\Python27\lib\site-packages\numpy\core\fromnumeric.py”, line 1800, in amax
    return amax(axis, out)
    ValueError: zero-size array to ufunc.reduce without identity

    Is there a workaround for this problem?

    • Curlew says :

      Hej, first of all. Please report future bugs at the bugtracker. The discussion on this page has already become too big. Lets also move your problem over the bug tracker. You can find the bug tracker here: http://hub.qgis.org/projects/lecos/issues?set_filter=1
      Create a new issue and report all necessary details (which qgis version, which system). Furthermore it would be create if you could upload a small sub-sample of your data for me to reproduce the error on my computer.

  26. Alexander pineda says :

    Hi i try to install Lecos but a have his mesagge: is recurire SPICY casualy you know how istall it in a ease way, Thanks a lot.

    • Curlew says :

      Yes, you need to install scipy within your qgis environment. I posted a tutorial for Windows here (https://conservationecology.files.wordpress.com/2012/10/24072013_howtoinstallscipyforqgis.pdf). It should still work for QGIS 2.0. If you’re running Linux, then just use your package manager. In fact all you need to know you can find on this page or via google…

      • Alexander Pineda says :

        Thanks for the tutorial, but after apply all recomendation continue asking about the Scipy when I try to install the Lecos complement. Casually You have any idea why it’s occurs?, It’s necessary unistall QGis before apply your tutorial?. I realy appreciate your help about it. Thanks.

        • Curlew says :

          I don’t know your system therefore i guess you have to uninstall it first. The OSGEO4W installer should install qgis within a single folder. Just try it out and stick exactly to the guide. Clean installs are always better 😉

  27. Justine says :

    Thanks for your help- really appreciate it.

  28. KS says :

    Hi Curlew,
    I’m really looking forward to using your plugin, thanks for all your hard work. I apologise if I should be posting this to the official bug tracker but I am a bit of a noob and can’t work out how to use it.

    I have QGIS2.0 installed, and I have bumpy (1.6.2) scipy (13.0) and PIL installed and imported into QGIS (everything downloaded from KyngChaos, I have a mac). When I attempt to install LecOS I get a message saying:

    The plugin is broken. Python says:
    cannot import name ni_support

    Do you have any idea what the problem might be?

    • Curlew says :

      Sorry, no i don’t. I have never owned a mac and i have never tried to install it personally. But i heard from colleagues that it worked for them using those sources.
      Maybe you contact the distributor directly and ask for advice how to install a correct setup

  29. Michael Friedhoff says :

    LecoS 1,9,2 does not work under installation of:

    a) Windows 7 / 64 bit
    b) QGIS-Version 2.1.0-Master QGIS-Codeversion 84f85d4
    d) osgeo4w-setup-x86_64
    c) OSWinPython 64bit / WinPython 64bit

    Error message still is “no module named scipy”.

    Any idea what to do ?

    Thank you for your assistance !

    • Curlew says :

      So did you specifically select in the advanced install list of packages that you want to install scipy, numpy and pil? Look into the tutorial for QGIS 1.8. The procedure should not be different.
      For me it worked that way.

      • karen says :

        Having the same issue wrt scipy. Using the advanced install, I found the numpy and pil packages (they were installed by default) but using the search function and then manually looking through the “libs” category I couldn’t find the python-scipy package… (or anything with scipy in it).

        Using pip in the OSGeo4W Shell, python-scipy didn’t exist.

        • Curlew says :

          Just installed it again on a colleagues pc and python-scipy is surely there (32bit OSGEO4W advanced install). Should be close below the python-numpy library. If it is definetly not there then i can not help you. Make a screenshot and ask the QGIS package maintainers.

          Scipy is a python module so obviously you want to install ‘scipy’ and not ‘python-scipy’ with pip. Sorry if this is all too confusing, but QGIS and GRASS were originally linux software products and its just a mess to look for failure causes on windows (especially remotely). You could also look for question on GIS stackexchange: keywords (“qgis python shapely” <- shapely because there are more posts, but the procedure should be the same)

        • karen says :

          Hmm, that might be the issue. I’ve been using the 64-bit install.

          Just checked the package lists–sure enough, compare 64-bit: http://download.osgeo.org/osgeo4w/x86_64/versions.html

          with the 32-bit:http://download.osgeo.org/osgeo4w/x86/versions.html .

          How disappointing! Guess I’ll have to switch over.

  30. pcav says :

    Better asking to add scipy to osgeo4w@64 bit than switching.

  31. Shabbir Khan says :

    Can I use this plugin to calculate the volume of overburden (cut and fill areas) of soil from surface elevation raster (before) and developed elevation raster (after)?

    • Curlew says :

      Depends on how your data looks alike. And if you refer with volume to a three-dimensional entity (LecoS is purely 2d).
      Please make your own thought and simply try it out. I merely provide a tool and not scientific assistance 🙂

  32. Justine says :


    Great Plugin! thanks its really helpful for my conservation work.

    I however am getting this error when trying to overlay a polygon and vegetation raster:

    n error has occured while executing Python code:

    Traceback (most recent call last):
    File “/Users/justinealexander/.qgis2/python/plugins/LecoS/lecos_dlg.py”, line 869, in accept
    File “/Users/justinealexander/.qgis2/python/plugins/LecoS/lecos_dlg.py”, line 944, in Output
    attr = func.getAttributeList(self.vector,self.LandID)
    File “/Users/justinealexander/.qgis2/python/plugins/LecoS/lecos_functions.py”, line 243, in getAttributeList
    for i in range(0,d.GetFeatureCount()):
    AttributeError: ‘NoneType’ object has no attribute ‘GetFeatureCount’

    Python version:
    2.6.1 (r261:67515, Jun 24 2010, 21:47:49)
    [GCC 4.2.1 (Apple Inc. build 5646)]

    QGIS version:
    2.0.1-Dufour Dufour, f738351

    Any help?

    • Curlew says :

      There is something wrong with your polygon file as the correct data-type was not passed. Try to save it again in another place as shapefile. Also make sure that the grouping Attribute has no NULL or NA values. This is all I can say from remote. If the error continues to occur, please raise a bug-report at http://hub.qgis.org/projects/lecos and upload a small sample subset of your data for me to replicate the error.

    • akshaysurendra says :

      I faced the same issue, but by simply clicking on the ‘edit’ option of the shapefile, the landscape attributes simply ‘appeared’ (I had selected all options, and used ‘attribute table’ instead of the file option. This is nearly a year later but I hope this helped you too!

  33. Pawel says :

    So to try this plugin I have to uninstall whole QGIS and reinstall it? Is it possible just to copy somewhere these python libraries?

  34. Edixon Gutiérrez says :

    Hi there guys,

    I just wanna ask about the plugin metrics and what each thing does. I am doing my research about landscape fragmentation but the units provided by LecoS are stil unknow to me (are they ha? or m2? are they m? or Km?) and I don’t understand many of its metrics, so I’ll be more than glad to recieve some guidance about this tool.

    Thnk you all very much

    • Curlew says :

      Hi, if you are run the tool via Processing there should be a help tab with explanations about what the tool is doing. Otherwise look into the LecoS plugin folder (~./.qgis2/python/plugins/Lecos/help). You can also look up all the metric you need in the fragstats documentation (http://www.umass.edu/landeco/research/fragstats/documents/fragstats_documents.html). I almost always took the formulas directly from there.
      Regarding Units: The important factors to consider are your rasters inherent cellsize. I don’t know what your grain is? Do you have 100x100m cells or 1ha cells? Most of the metrics of LecoS and other tools count underlying raster cells and multiply them with the cellsize.

      • Edixon Gutiérrez says :

        I have QGIS 2.4 version Installed and no explanation in help tab, not sure if it’s a bug or a simple error of my version. Also I’m having issues when I tried to export data as .csv.

        About cellsize I’ll check it but I think is 10x10m due that is a raster made from a shpe in 1:25000 scale, maybe a bit less.

        Thanks for the pdf I’ll be reading it and also thanks for your help.

  35. Sa says :

    Where can I find the description of algorithms used in Lecos (effective mesh size, …) ?

  36. Michael Curran says :


    I could not find the description of Mean Patch Distance in the FRAGSTATS documentation, because the nomenclature between the two programs is different. There is no index in FRAGSTATS called Mean Patch Distance.

    I ask because the results for my dataset are in strange units. All other area and distance statistics are expresed in map units, which in my case are meters (World Mollweide projection). Thus they are very large (thousands to millions). The Mean Patch Distance metric however gives me very small values (less than 1 to hundreds). Thus could not be in meters, as my raster resolution is 1 km, thus two forest patches separated by 1 cell of non-forest must be at a minimum 1000 m apart.

    What exactly is being calculated?

    Thanks in advance,

    • Curlew says :

      I am not so sure about your projection, but maybe you stumbled on a bug. I would advise to subset your data to a smaller window of interest and repeat the calculation. The metric is quite simple and is also known as Euclidean nearest neighbor distance (ENN) in Fragstats (http://tinyurl.com/puwn4lj). If you look into LecoS code (landscape_statistics.py) you can see that it first computes the euclidean distance between patches (http://tinyurl.com/oq442ux) and then calculates the mean of the distances and multiplies it with the cellsize. Is this all right for your projection? Sadly nowadays I don’t have that much time to adapt the LecoS code much more so tell me If you found a workaround…

      • Michael Curran says :

        Thanks for the quick reply, I have tried at neighbourhood sizes of 10, 25, 50 and 200 km, and get similar results. But now I do think it has to do with the projection of the forest data, as ive had some issues already that I thought were sorted out. I checked my cell size which was 999.995 m X negative 1000 m. Dont know why the negative is in there, but maybe this is causing the issue. In any case, probably a false alarm, but will come back to you if I can verify it with a proper dataset.

        In any case, the relative values look plausable, and there is a good correlation with edge length and 1/forest proportion in my data (i.e. more edgy and less forested landscapes have larger distances). Thus it appears working.
        Thanks again,

      • Michael Curran says :

        Hi, I am still puzzled by the strange results I get from the nearest neighbour distance (a year later). I am an amateur in Python, but looking at the lecoS code, I cannot understand what the “cellsize” variable actually is. A cell has both as x and y dimension, which may differ if the projection involves warping. So when you say “multiplies it with the cellsize”, which cell soze do you mean (x or y dimension)?

        • Martin Jung says :

          Hey Michael,
          Can you please update your LecoS version? I removed the NN distance calculation for now(rather than letting users compute wrong values), because I could not figure out the cause for the strange values and don’t have so much time to investigate it more through. Also see this bug-report: http://hub.qgis.org/issues/11710
          In general:
          The cellsize is taken from metadata within your raster layer. These are normally saved within the file. You can see the values if you go to QGIS > Layer properties > Metadata > Look for Pixel Size.
          LecoS assumes that pixels are square! So both the x and y dimension are assumed to have equal values and cells are perfect squares.

  37. Romaike says :

    When trying to Install Lecos plugin (v 1.9.3) in QGIS (v 2.6.0-Brighton) on Mac OSX (v. 10.9.2). I receive the following error message:

    “The plugin is broken. Python said:
    No module named outputs.OutputVector”

    Would you know what is causing this error and what I can do to fix it?

  38. pcav says :

    The plugin has to be upgraded to QGIS 2.6. Ticket open, please consider helping with this.

  39. Simone says :

    Hi all!!

    I’m Simone phd student. My research focus on ecological processes in marine coastal ecosystems. I’m really interesting in landscape ecology approach and thank you very much for this plugin!.. I’m estimating predation rate on sea urchins in different landscape heterogeneity and I wouldto study hotspots in relatation with environmental predictors. I download Lecos to calculate landscape parameters to compare values at different patch classes and among different landscapes.
    The programme works fine but I really don’t know why any estimation of the patch class number 0 (the first one) is always “none” !!

    Could anybody suggest my some option??

    Thank you very much and sorry for the very basic question!


    • Curlew says :

      Hi Simone,
      this is not a forum and it just me here 🙂 Sadly I cannot help you like this without knowing the structure of your data. Values having None could be multiple reasons. Check your projection (is it meter based), your alignment (are the polygons covered by the raster), the no-data value of the raster (is it set). Try to draw a new polygon somewhere over the number 0 and redo the calculation. These are just some suggestions. Try it out.

  40. Simone says :

    Hi Sadly, thank you to answer me. I can’t found any forum about this!

    My data are very simple, I have a grid 7x7cells (each cell is 5x5meteres) and my grain of information is the cell.
    For each cell I have numerical variables such as predation risk, rugosity of substrate, canopy height but also a categorical variable that is the type of habitat and in this case I made a code from 0 to 3 in relation to the four classes of habitats.

    I rasted the grid representing each class of habitat with four colours. I think the projection is fine because I can see the raster in Qgis. In the properties there are the four class of habitats with the assigned colour but nothing else.

    so, when I run Lecos I set up as “cellsize” 5m, and as “no-data” a number different after 3 (my class scale is from 0 to 3 and I don’t know exactly what I have to write here).
    Lecos runs fine but the output is a table with the class 0 values Always none.
    I repeated the same for example for predation rate that is four classes like the habitat (0-0.25=class0, 0.25-5=class1…) but the same.
    Class0 is Always none. I really can’t understand why because also I don’t find a user guide! Please can you say me how can I check this problem???
    thank you very much and really sorry to insist on this!

    • Curlew says :

      I am sorry, but I can not help you from remote. There a many things you might have missed. If you really want me to help you, then write me a mail under contact and include a subset of your data (not everything, just crop your layers and upload to a hoster), so that I can try it out.

  41. chandu says :

    I love your plugin, but I am finding that after I upgraded to QGIS 2.8.1, if I have LecoS installed, then when i quite QGIS, it triggers an error message with a ‘minidump of memory’ or something like that. Uninstalling LecoS stopped the problem. I am using 64-bit QGIS 2.8.1 on a 64-bit Lenovo Thinkpad running Win7 Pro 64-bit.

    • Curlew says :

      Sorry to hear that, but I am not sure what I can do to help you. It likely has to do sth. with your python installation. LecoS runs perfectly for me (Debian Linux, all QGIS versions) and there were no crashes on other peoples computers (saw it run perfectly on Windows and Mac computers last week) as well…

  42. Jakob says :

    It seems your helpfiles got lost somewhere within the QGIS updates?

    When I try to access the help for the LecoS modules I get the error:

    “Not Found

    The requested URL /2.6/en/docs/user_manual/processing_algs/lecos/landscape_vector_overlay/overlayrastermetricspolygons.html was not found on this server”

  43. Dan says :

    I’m struggling to get LecoS working on my Mac OS X (10.10.3), QGIS 2.8 Wien. I have installed all the requisite Pythons bits-and-bobs and used the Plugin manager to install LecoS. When I run the LecoS Landscape Vector Overlay, I get NULL values for the means in all polygons. However, when I run the Zonal Statistics plugin on the same polygon and rasters layers I get good results – so it doesn’t appear to be a problem with these layers. Any suggestions?

    • Curlew says :

      Check if reprojecting both layers works. Try a subset of your polygons or a quick hand-drawn shape. Also try to avoid any complex polygon shapes like “multipolygons” types. If you still think this could be a bug, please upload a subset of your data on the bugtracker, so that I can take a look.

  44. Suzete Cabaceira says :

    Hi all!!

    I downloaded Lecos to compare values of metrics for land use grids of 10×10 km. I’m not interested in metrics’ values by classes but for all patches inside the grid.

    Could anybody suggest how to obtain those overall values?

    Thank you very much and sorry for this basic question!

    Suzete Cabaceira

  45. Malc Burgess says :

    This is great.

    Any plans to add the Landscape Metric ‘contagion index’? I could really use this and FRAGSTATS (function CONTAG) can’t deal with the large datasets I am trying to use. If not has anyone written an R function to calculate contagion?

    • Curlew says :

      Not as far as I know. There are as many metrics as there are publications about them. Currently I have nether the time nor funds to further develop LecoS. But I might remember it for later.

  46. Indra Kumara says :

    Dear Sir,

    I have just instal qgis 2.10 and plugin Lecos 1.9.8, but the plugin cause dump crash when qgis exit. i use windows 8.1 on my notebook (Lenovo Yoga S1). I have save the file but I dont know to send it to you, I can not find the way how to send bug report for plugin in qgis. Thank you.

  47. Diogo Caribé says :

    I have one trouble when I run polygon bach overlay. I’m using Qgis 2.8.5 (32 bits), Win 7 (64 bits). Can you help me what I need to do?

    An error has occured while executing Python code:

    Traceback (most recent call last):
    File “C:/Users/diogo/.qgis2/python/plugins\LecoS\lecos_dlg.py”, line 892, in accept
    err, r = bat.go(cmd,None,cellsize,None,rasE)
    File “C:/Users/diogo/.qgis2/python/plugins\LecoS\landscape_polygonoverlay.py”, line 151, in go
    array = self.getClipArray(poly)
    File “C:/Users/diogo/.qgis2/python/plugins\LecoS\landscape_polygonoverlay.py”, line 334, in getClipArray
    rasterPoly = Image.new(“L”, (pxWidth, pxHeight), 1)
    File “C:\PROGRA~2\QGISWI~1\apps\Python27\lib\site-packages\PIL\Image.py”, line 1763, in new
    return Image()._new(core.fill(mode, size, color))
    File “C:\PROGRA~2\QGISWI~1\apps\Python27\lib\site-packages\PIL\Image.py”, line 37, in __getattr__
    raise ImportError(“The _imaging C module is not installed”)
    ImportError: The _imaging C module is not installed

    Python version:
    2.7.4 (default, Apr 6 2013, 19:54:46) [MSC v.1500 32 bit (Intel)]

    QGIS version:
    2.8.5-Wien Wien, 2b32796

    Python path: [‘C:/Users/diogo/.qgis2/python/plugins\\processing’, ‘C:/Users/diogo/.qgis2/python/plugins\\LecoS’, ‘C:/PROGRA~2/QGISWI~1/apps/qgis-ltr/./python’, u’C:/Users/diogo/.qgis2/python’, u’C:/Users/diogo/.qgis2/python/plugins’, ‘C:/PROGRA~2/QGISWI~1/apps/qgis-ltr/./python/plugins’, ‘C:\\PROGRA~2\\QGISWI~1\\bin\\python27.zip’, ‘C:\\PROGRA~2\\QGISWI~1\\apps\\Python27\\DLLs’, ‘C:\\PROGRA~2\\QGISWI~1\\apps\\Python27\\lib’, ‘C:\\PROGRA~2\\QGISWI~1\\apps\\Python27\\lib\\plat-win’, ‘C:\\PROGRA~2\\QGISWI~1\\apps\\Python27\\lib\\lib-tk’, ‘C:\\PROGRA~2\\QGISWI~1\\bin’, ‘C:\\PROGRA~2\\QGISWI~1\\apps\\Python27’, ‘C:\\PROGRA~2\\QGISWI~1\\apps\\Python27\\lib\\site-packages’, ‘C:\\PROGRA~2\\QGISWI~1\\apps\\Python27\\lib\\site-packages\\PIL’, ‘C:\\PROGRA~2\\QGISWI~1\\apps\\Python27\\lib\\site-packages\\jinja2-2.7.2-py2.7.egg’, ‘C:\\PROGRA~2\\QGISWI~1\\apps\\Python27\\lib\\site-packages\\markupsafe-0.23-py2.7-win32.egg’, ‘C:\\PROGRA~2\\QGISWI~1\\apps\\Python27\\lib\\site-packages\\python_dateutil-2.2-py2.7.egg’, ‘C:\\PROGRA~2\\QGISWI~1\\apps\\Python27\\lib\\site-packages\\pytz-2014.2-py2.7.egg’, ‘C:\\PROGRA~2\\QGISWI~1\\apps\\Python27\\lib\\site-packages\\win32’, ‘C:\\PROGRA~2\\QGISWI~1\\apps\\Python27\\lib\\site-packages\\win32\\lib’, ‘C:\\PROGRA~2\\QGISWI~1\\apps\\Python27\\lib\\site-packages\\Pythonwin’, ‘C:\\PROGRA~2\\QGISWI~1\\apps\\Python27\\lib\\site-packages\\Shapely-1.2.18-py2.7-win32.egg’, ‘C:\\PROGRA~2\\QGISWI~1\\apps\\Python27\\lib\\site-packages\\six-1.6.1-py2.7.egg’, ‘C:\\PROGRA~2\\QGISWI~1\\apps\\Python27\\lib\\site-packages\\wx-2.8-msw-unicode’, u’C:/Users/diogo/.qgis2//python’, ‘C:\\PROGRA~2\\QGISWI~1\\apps\\qgis-ltr\\python\\plugins\\fTools\\tools’]

    • Martin Jung says :

      The “error” is here: ImportError(“The _imaging C module is not installed”)

      You don’t have a valid python-imaging library installed (PIL). Reinstall using the osgeo4w installer. There should be no error or message if you open plugins -> python console and enter: ‘ import PIL’

  48. Rebecca says :

    I do not think this is a bug, but rather my ignorance of Python or QGIS at work.

    I am running Wien on Windows. I tried using the Landscape vector overlay tool, with no results. I am using a .shp file of a single circle as the overlay grid and a Cropscape raster file as the landscape layer. I selected only the “save in attribute table” and the “Shannon Index” options. Although I get the “values were added…” message, there is nothing new in the attribute table for the .shp file.

    Am I missing something?

    • Martin Jung says :

      The attribute should be there, but the dbf file of the shapefile does not get updated automatically. Try to remove the file and add it again as vector layer. If it is still not there, then just save as csv and do a join 🙂

      • Rebecca says :

        It worked! Now to move on to trying it with all 80 of my polygons in the .shp file instead of my test file that just had the one.

        Awesome plugin!

  49. Gabriela says :

    hi, i have a problem, i am trying to use the plugin but when i run the program this error appears, i have been tried different things but i don’t know what other things to do, please help, thanks

    AttributeError: ‘NoneType’ object has no attribute ‘GetFeatureCount’
    Traceback (most recent call last):
    File “C:/Users/carlitos/.qgis2/python/plugins\LecoS\lecos_dlg.py”, line 876, in accept
    File “C:/Users/carlitos/.qgis2/python/plugins\LecoS\lecos_dlg.py”, line 951, in Output
    attr = func.getAttributeList(self.vector,self.LandID)
    File “C:/Users/carlitos/.qgis2/python/plugins\LecoS\lecos_functions.py”, line 245, in getAttributeList
    for i in range(0,d.GetFeatureCount()):
    AttributeError: ‘NoneType’ object has no attribute ‘GetFeatureCount’

    Versión de Python: 2.7.5 (default, May 15 2013, 22:44:16) [MSC v.1500 64 bit (AMD64)]
    Versión de QGIS: 2.12.3-Lyon Lyon, 99ac688

    Ruta de Python:

    • Martin Jung says :

      LecoS could not read the shapefile correctly. Did you load it from disk or is it created in memory via a function/tool. Please raise a bug report and attach a self-reproducing sample rather than posting here

  50. Luca says :

    Hi Curlew!
    I find your plugin really useful: thanks a lot!
    However I’ve an issue regarding Edge length using the vector overlay. I want to calculate some metrics within circular buffers but the edge length, from what I understand, is given by the sum of the edge of a given patch plus the edge of the buffer cutting the patch. For istance, if the buffer falls totally within a homogeneous and larger patch, the edge length reflects the buffer edge rather than the desirable null value…

    Many thanks
    Luca (the Bittern… 😉 )

    • Martin Jung says :

      Well, In the patch dynamic framework your defined buffer becomes your “landscape” and thus the boundary counts as border of your landscape. The results LecoS is calculating is identical to estimates from SDMTools (R) or FragStats default calculations (but see http://tinyurl.com/j33sonh ). I could manually set the calculation of Edge length to zero if the entire patch is composed of a single class, but what to do if half of the patch is composed of the focal class and the other half of another class. That way the plugin would still include the boundary edge length of the focal class side. Ether exclude the boundary of the landscape all together (could be undesired) or incorporate it into the calculations.

  51. Luca says :

    Thanks for the quick reply.
    The case of a single patch, largen than the overlaying polygon is obviously a unique case which I mentioned as an example. I realize that one should find an universal method and that probably ther is no a simple way to solve the issue. I’ll try to calculate the edge length within the outermost ring of the buffer and thus to rectify, by sutraction, the value measured for the whole buffer.
    Perhaps such procedure could be implemented within your powerful plugin (but I don’t know how complicated this will be…)
    Thanks again!

  52. Diogo Caribé says :

    This plugin is much useful.

    I have been studied it to taste more its functions.

    In my state, we are trying to disseminate it for enviromenmtal managers. We did a course where we propused to learn more about it. However, all computer had bug answer.

    Many of computer had windows 10 and 8.

    Thanks again.

  53. Mario says :

    Hi Martin,
    I am writing to enquire about Lecos QGIS plugin. I have a number of buffers with CLC landcover data and am trying to extract landscape metrics for each of this buffers. The csv output of this analysis provides me with the requested metrics for each class with a unique number.
    How are the class numbers calculated, and in my case, what would be the relationship between the class number and the clc code?
    And, is it possible to relate these values to different buffers?

    Hope you can help with this.

    Thanks in advance.

    • Martin Jung says :

      I can not tell you what the class number represents as they depend on your input raster. Ether look at your metadata/documentation or use the identify function in QGIS and click on a cell whose code you know.

      • Mario says :

        Thank you for your assistance … this worked out well.

        I have calculated the landscape metrics for each of these classes now. However, when checking the different classes in the output file I realise that rows belonging to specific classes are missing (around 20 out of 150). I have double checked this by recreating the raster file from the vector with polygons, using the GRASS plugin, but have not been able to get metrics for these 20 classes (which are clearly shown in the attribute table of the original vector file).
        No errors were encountered during the calculation of the metrics. Are there any reasons why this would happen?

        • Martin Jung says :

          Likely they don’t overlay? Double check what you are extracting and through which mask. Also realize that I can not help you remotely and also don’t have the time for that! If you think this could be a bug, then raise a bug-report and attach a subset of your data for me to reproduce the error.

  54. kljuni says :

    Hello, I am using Lecos to calculate Shannon’s index of land use diversity for my 130 buffers of 800 m diameter. I have a raster with cell size 1 m. I started the Landscape vector overlay tool but when i hit start the QGIS freezes and is not responding. First i thought it is processing the data but after 15 h + it still did not finish… But even if I try to calculate only one buffer of 800 m diameter it freezes. Is it not working for me? Too much data, too little memory? How much time should such a calculation take?

    • Martin Jung says :

      Depnds on the size of your input and your system specifications. Try the following: Crop your input raster to the extent of one of your buffer features. Then try again to calculate.
      Imagine that the script loads your entire raster layer into memory. So if your 1m raster layer is already greater than the available memory on your system, then you will run into problems. If you think it is a bug, then please report it on github ( https://github.com/Martin-Jung/LecoS ) and attach a test dataset.

  55. Ludovico says :

    Hi Martin, I have a question regarding the Mean Shape Index. How is it calculated? From the Fragstats help page, MSI can assume values ranging from 1 to infinite. It approaches to 1 when patches are square. However I have found only values lesser than 1 in LecoS.

  56. Patricia Sanches says :

    Hi Martin,

    Iam not sure if my question is related to the last one, but I would like to know if there is a similar metric in Lecos for SHAPE INDEX_MEAN (this is the name of this metric in Fragstat).

    This metric is a normalized ratio of patch perimeter to area in which the complexity of patch shape is compared to a standart shape (square) of the same size, thereby alleviating the size dependency problem of Perimeter-area ratio.



  57. (another) Martin says :


    while trying to use the LecoS plugin, I have encountered (but only for _some_ functions) Python “TypeErrors” which I am unable to deal with.

    I tried the bug reporting link as advised above, but it four-oh-foured.
    On the main QGIS bug reporting site I could not find a section dedicated to Lecos specifically, and in any case the whole system there is somewhat intimidating (OSGeo account? mantras? black cocks at midnight? :-)).

    So I have put my report with details here, if you want to have a look:

    Comments would be appreciated.
    And many thanks for this splendid plugin!

    (another) Martin

    • Martin Jung says :

      Hey Martin,
      The bug tracker link is indeed not working anymore. Thanks for noticing. The QGIS team (which I am not involved with) are gradually urging plugin authors to move their plugins to github ( a code hosting platform). This is also where you can report bugs and find the sourcecode of the plugin. https://github.com/Martin-Jung/LecoS/issues

      If you think you found one, please attach a small subset (clipped) of your files for me to reproduce the error.
      The code error in your text file sounds as if you are using an older numpy version (you could try to update via osgeo4w). But could also be sth. else.
      The landscape overlay error is somehow related to whatever you are using as ID variable in the polygons. Some “umlauts” maybe? Or some strange columntype?

      I need to be able to reproduce the error to figure out what is going on.


      • (another) Martin says :

        Hello Martin,

        thank you for the fast reply!

        I have now reported the issue (if it is one…*) on github, and have included a small test data set.
        Note that some more comments have been added to the text report.

        In short:

        — I have verified that my current QGIS installation (v.2.18.2) is using the numpy version (1.11.0) which it brought itself (and not the one from an older QGIS 2.2 which I also have still installed).

        — I have so far only used the default variable name (“id”) for the ID variable of shapes. No umlauts or other extravaganzas, except for underscore and dash in *layer* names.
        (Just in case I removed those, too, for testing, but it made no difference.)

        (another) Martin

        * My feeling is (from long experience in user support) that this may well be newbie user (i.e. my) error or ignorance, and not a Lecos bug; but I hope that, too, can be sorted 🙂

  58. Cathy Newman says :

    Awesome plugin! I only discovered it today while searching around for Fragstats information. This is so useful! The only problem I’ve run into is that it seems like there’s an upper limit of 999 on cellsize, and many of my rasters (species geographic range maps in North America Albers Equal Area projection) have cellsizes much larger than 999m because to rasterize the polygon range maps I used the default ArcGIS cellsize of [(shortest of L or W)/250]. Perhaps for my purposes, dividing cellsize by some factor of 10 and then converting the results will be sufficient.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: