LecoS

Description:

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.

Disclaimer:

LecoS is released under a general GPL license 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 an upcoming little article about LecoS.

Download:

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).

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-imaging) 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).

Citation

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

Current version: 1.9.2

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.

81 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.
    Thanks.

  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 :

    Hi.
    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 :

    Hi
    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()
    method

    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__
    self.startup()
    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).

      EDIT:
      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.

    cheers

    Klaus

    • 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
      self.NoDataVal.setValidator(QDoubleValidator(-999999,999999,5))
      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

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

      QGIS-Version:
      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 )

      EDIT:
      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.

    Best,
    Tim

    • 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 :

    Hello,
    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 (http://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 :

    Hello,
    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 2.7.5.3 / WinPython 64bit 3.3.2.3

    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 :

    Hello,
    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 :

    Hello,

    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
    self.Output(results)
    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.

  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 :

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

  36. Michael Curran says :

    Hi,

    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,
    Mike

    • 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

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

Follow

Get every new post delivered to your Inbox.

Join 80 other followers

%d bloggers like this: