Closed hagen5 closed 7 years ago
Thanks for reporting and providing a test file! Confirmed both errors as bugs. One was an undetected typo and the other occurs because of change to the ogr python module.
1.) Now fixed here on Github. Updated version hopefully soon also in the QGIS plugin repository. (If you can't wait: just download the github archive and replace the contents of the zip file with the files in your .qgis2 python plugin folder)
2.) Bit baffled about this one. Will investigate further in next days. It worked before so something must have changed between QGIS versions. Also note that if you deselect both "Save into file" and "save into attribute table" it still works. Another option is to use the LecoS Processing interface in the meantime.
Thanks! (Glad to hear it wasn't just me... :-) )
1. I can confirm that with the new version from Github, all "global" landscape metrics can now be calculated. However, in order to get this to work I encountered a new issue. Now already solved, but it may (or may not) be relevant to issue 2 below, hence reported here: After installing the new Github version, the plugin was initially flagged as broken (QGIS Plugin Manager), because metadata.txt could not be read. As it turned out, this file as downloaded from Github used UTF-8(B), i.e. UTF-8 encoding with Byte Order Mark (BOM), and also used x0A (LF) for line-end marker. Apparently QGIS cannot digest this, at least not when running under Windows 7. Problem could be fixed by removing the BOM and converting from Unix-style line ends x0A (LF) to DOS/Window style x0D0A (CRLF).
2. As some people (links in my earlier report) claim this somewhat weird error message ("...argument 2 of type 'char const *'") may also have to do with Unicode under Python, I tried to find out what kind of Unicode (more precisely, UTF-8 vs. UTF-16) Windows 7 actually uses. But figuring this out for various Windows versions is a can of worms, the understanding of which would require (for me) a project of its own. See e.g. here...
It might however be interesting to find out if that error occurs also when QGIS/LecoS are run under a Linux (or Mac) OS, which may (or may not) better be able to deal with Unicode. Unfortunately I cannot test it myself as I don't have a Linux box (yet).
Deselecting "Save in file / attribute table" avoids a crash indeed, and the selected variables are correctly listed in the resulting table, but all have the value "None". (I have read that one reason can be different CRSes for different layers, but that is not the case here. May be I am doing something else wrong.)
I had so far completely missed the Processing interface for LecoS, thanks for the hint. Using "Overlay raster metrics (polygon)" produces a CSV file, but with empty values ('') only. But again, that may just be me not understanding things yet.
Hello this error has happened while I try to calculate some landscape metrics using the lecos:
An error occurred while executing the code Python:
Exception: tostring() has been removed. Please call tobytes() instead. Traceback (most recent call last): File "/Users/welvisfelipe/.qgis2/python/plugins/LecoS/lecos_dlg.py", line 872, in accept err, r = bat.go(cmd,cl,cellsize,None,rasE) File "/Users/welvisfelipe/.qgis2/python/plugins/LecoS/landscape_polygonoverlay.py", line 151, in go array = self.getClipArray(poly) File "/Users/welvisfelipe/.qgis2/python/plugins/LecoS/landscape_polygonoverlay.py", line 354, in getClipArray mask = self.imageToArray(rasterPoly) File "/Users/welvisfelipe/.qgis2/python/plugins/LecoS/landscape_polygonoverlay.py", line 249, in imageToArray a = numpy.fromstring(i.tostring(),'b') File "/Library/Python/2.7/site-packages/PIL/Image.py", line 695, in tostring "Please call tobytes() instead.") Exception: tostring() has been removed. Please call tobytes() instead.
Versão do Python: 2.7.10 (default, Oct 23 2015, 19:19:21) [GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] Versão do QGIS: 2.14.0-Essen Essen, exported
Hi @welvisfelipe , The latter error is not related to this problem. Your QGIS version is outdated (2.14, we are moving towards 2.18) and the libraries you seem to use don't have the toString function. Please update QGIS and Numpy + scipy.
Related to this bug: I will try and see if I can find some time soon to test and fix it on my linux machine (which has better unicode handling).
@hagen5 Pushed another update. Try that out. Now all queries are manually enforced to be UTF-8. Should fix that error.
On a side note. Make sure that your polygons are contained within your raster's extent. Your test polygon computation still fails as its extent is larger than the input raster. With this test polygon it works. CenterTestPoly.zip
Thanks! This is just to confirm that everything now works fine for me, too.
Make sure that your polygons are contained within your raster's extent.
Thanks for the hint, I wasn't aware that isn't allowed. With this new update, even though the tables layout was now fine, I initially still saw "None" for all values. But once my grid extent had been reduced to lie completely inside the raster layer extent, all was well indeed.
Thanks again for your support! LecoS is an excellent tool, and I'm happy that I can now use it.
Thanks Martin, the problem was resolved, the Lecos is a great plugin and now I can use in my work...
On Feb 20, 2017 08:33, "hagen5" notifications@github.com wrote:
Thanks! This is just to confirm that everything now works fine for me, too.
Make sure that your polygons are contained within your raster's extent.
Thanks for the hint, I wasn't aware that isn't allowed. With this new update, even though the tables layout was now fine, I initially still saw " None" for all values. But once my grid had been reduced to lie completely inside the raster layer, all was well indeed.
Thanks again for your support! LecoS is an excellent tool, and I'm happy that I can now use it.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Martin-Jung/LecoS/issues/7#issuecomment-281017050, or mute the thread https://github.com/notifications/unsubscribe-auth/AYjerztjCHbLGakcm2T3oqnPEaTlWR9yks5reU_VgaJpZM4LeIgm .
Landscape Metrics tab When trying to calculate min., max., or median, this error is thrown: TypeError: amin() [or respective other function] got an unexpected keyword argument 'dtype' Other metrics can be calculated OK.
Landscape Vector Overlay tab All calculation attempts here result in TypeError: in method 'DataSource_ExecuteSQL', argument 2 of type 'char const *'
Full details and test data are in the attached report. Lecos_Issues_ME.zip