Martin-Jung / LecoS

LecoS QGis Plugin - Contains several analytical functions for land cover analysis

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

update LECOS to work on QGIS 3.2

kdarras opened this issue · comments

Hi Martin,
it would be awesome if LecoS worked on the newer, excellent QGIS 3.2. Any plans to implement this?

Absolutely no time for this at the moment, sorry. I might do it at some point, but it is unlikely in the near future

I'm working on it and already submitted a pull request, hope it is working fine, you can test it from my fork in the QGIS3 branch.

Cheers again for this @caiohamamura Tested it and at most functions in the processing toolbox generally seem to work. Now merged with experimental QGIS3 branch.

Open issues still:

  • I have not assessed all functionalities of the plugin yet. I uploaded some Lecos testdata here ( http://www.filedropper.com/lecostestdata )
  • The GUI under Menu -> Raster -> Landscape ecology does not seem to function anymore. Tested for Landscape statistics and the polygon batch overlay, both of which return Python errors.
  • Compared to previous versions, outputs from the Landscape statistics toolset are not automatically added to the ToC anymore.
  • nlmpy functionalities remain untested. Need to update my library before this can be assessed.

Hi @caiohamamura,

Great work.
The GUI seems to work now as far as I can see. The nlmpy algorithms do work as well.
I have not yet tested all algorithms, but found a number of other issues that did not happen before.

  • The query raster values tool returns an error that previously did not occur
/lecos_sextantealgorithms.py", line 922, in processAlgorithm
lyr = ds.GetLayer()
AttributeError: 'NoneType' object has no attribute 'GetLayer'

  • The vector overlay returns an error for all algorithms. Probably wrong library connection or similar. Test it out with the data I supplied.
Processing algorithm…
Algorithm 'Overlay raster metrics (Polygons)' starting…
Input parameters:
{ 'ADDTABLE' : False, 'CMETRIC' : 1, 'IS_CLASS' : True, 'LAND_GRID' : 'TEST_Lecos.tif', 'LC_CLASS' : 11, 'LMETRIC' : 0, 'OUTPUT_FILE' : 'memory:', 'VECTOR_GRID' : 'test_center.shp' }

Traceback (most recent call last):
File "/home/martin/.local/share/QGIS/QGIS3/profiles/default/python/plugins/LecoS/lecos_sextantealgorithms.py", line 856, in processAlgorithm
f = open(output, "wb" )
TypeError: expected str, bytes or os.PathLike object, not NoneType

  • Something that I found somewhat annoying is that processing created raster files seem to ignore the project CRS, which did not happen before in QGIS 2. Do you happen to know how to query the currently set CRS and set it as default for all created files? At the moment raster files from the Landscape preparation NLMpy toolbox use WGS84 by default
  1. I couldn't reproduce the error ds.GetLayer(), maybe the algorithm should check if vectorLayer is valid
  2. Yes, this one could actually be fixed quite easily if we do not need to add the table automatically. I've already commited a fix.
  3. Actually I had already changed createRaster within lecos_functions.py to get QgsProject.instance().defaultCrsForNewLayers().authid(), I'll check what's going on.

Oh I see I changed the default behavior of createRaster, before it was assigning the epsg of the active layer:

qgis.utils.iface.activeLayer().crs().authid()

But I though that maybe there isn't an activeLayer, since the user can actually run the algorithm with no layers in the project at all. Instead it uses the current project epsg.

Maybe it should check there is an activeLayer selected, if there isn't then get the project crs. What do you think, will it be confusing to the user?

Thanks a bunch @caiohamamura for all your help.
Everything seems to work as far as I can see.
I have created a new release and uploaded it to the QGIS plugin server from which it should become available soon'ish

Thanks again for your help.

It is now available through the QGIS plugin server.