UMEP-dev / UMEP

Urban Multi-scale Environmental Predictor
https://umep-docs.readthedocs.io/
59 stars 15 forks source link

tree generator results in error #452

Closed jkblizzard closed 1 year ago

jkblizzard commented 2 years ago

When I want to apply the tree generator, I receive the following error message

An error has occurred while executing Python code:

IndexError: too many indices for array: array is 1-dimensional, but 2 were indexed Traceback (most recent call last): File "/home/jk/.local/share/QGIS/QGIS3/profiles/default/python/plugins/UMEP/TreeGenerator/tree_generator.py", line 386, in start_progress cdsm_array, tdsm_array = makevegdems.vegunitsgeneration(build_array, cdsm_array, tdsm_array, ttype, height, File "/home/jk/.local/share/QGIS/QGIS3/profiles/default/python/plugins/UMEP/TreeGenerator/makevegdems.py", line 60, in vegunitsgeneration trees = trees[int(rowcutmin):int(rowcutmax), int(colcutmin):int(colcutmax)] IndexError: too many indices for array: array is 1-dimensional, but 2 were indexed

Python version: 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110] QGIS version: 3.10.14-A Coruña A Coruña, exported

Python Path: /home/jk/.local/share/QGIS/QGIS3/profiles/default/python/plugins/UMEP/SUEWSPrepare/Modules /usr/share/qgis/python /home/jk/.local/share/QGIS/QGIS3/profiles/default/python /home/jk/.local/share/QGIS/QGIS3/profiles/default/python/plugins /usr/share/qgis/python/plugins /usr/lib/python39.zip /usr/lib/python3.9 /usr/lib/python3.9/lib-dynload /home/jk/.local/lib/python3.9/site-packages /usr/local/lib/python3.9/dist-packages /usr/lib/python3/dist-packages /home/jk/.local/share/QGIS/QGIS3/profiles/default/python . /home/jk/admin/eigen/jobs/graw/solPot

I have updated numpy and installed all required python packages so far. I have converted all nodata to '0', boundaries and pixelsize of the dem/dsm are the same. Similar issues on github have no effect. I am a bit desperate at the moment.... Thanks in advance for any hint.

nilswallenberg commented 2 years ago

Hi jkblizzard,

Can you please attach your data.

Cheers, Nils

jkblizzard commented 2 years ago

Dear Nils, I am not sure whether I should upload my data here. However, GIS data formats are not allowed at GitHub. I have sent these data via email a few days ago, and I hope they arrived well. Please, let me know, if you need more information or data. Thanks a lot for your effort in advance. Cheers Jörg

nilswallenberg commented 2 years ago

Hi Jörg,

I have not received an email with the data. It is possible to upload a zip-file here on GitHub. If that is not possible, please try and email again.

What is the resolution of your dem/dsm?

Cheers, Nils

jkblizzard commented 2 years ago

treeGen.zip Hi Nils, thanks a lot for your instant response. Sorry for the mail failure. I am not sure what went wrong. My sent folder says mail is sent. I am trying again uploading a tree point shape a building dsm and the underlying dsm here in git using a zip file. I hope it works this time. The resolution for both dsm and dem is 1m. Thanks again for your effort. best Jörg

nilswallenberg commented 1 year ago

Hi Jörg,

I think I fixed it. There were three trees at the very top of the domain that were to close to the edge of the dsm/dem. They should have been ignored by the code.

You can download the latest version here at GitHub (both UMEP and UMEP for processing) and install from zip and it should work. Otherwise, get back to me. :)

Cheers, Nils

jkblizzard commented 1 year ago

Hi Nils, again thanks for the quick reply. Unfortunately, I have got the same error report after employing the corrected makevegdems.py, except this time it is line 61 instead of 60.

An error has occurred while executing Python code:

IndexError: too many indices for array: array is 1-dimensional, but 2 were indexed Traceback (most recent call last): File "/home/jk/.local/share/QGIS/QGIS3/profiles/default/python/plugins/UMEP/TreeGenerator/tree_generator.py", line 386, in start_progress cdsm_array, tdsm_array = makevegdems.vegunitsgeneration(build_array, cdsm_array, tdsm_array, ttype, height, File "/home/jk/.local/share/QGIS/QGIS3/profiles/default/python/plugins/UMEP/TreeGenerator/makevegdems.py", line 61, in vegunitsgeneration trees = trees[int(rowcutmin):int(rowcutmax), int(colcutmin):int(colcutmax)] IndexError: too many indices for array: array is 1-dimensional, but 2 were indexed

Python version: 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110] QGIS version: 3.10.14-A Coruña A Coruña, exported

Python Path: /home/jk/.local/share/QGIS/QGIS3/profiles/default/python/plugins/UMEP/SUEWSPrepare/Modules /usr/share/qgis/python /home/jk/.local/share/QGIS/QGIS3/profiles/default/python /home/jk/.local/share/QGIS/QGIS3/profiles/default/python/plugins /usr/share/qgis/python/plugins /usr/lib/python39.zip /usr/lib/python3.9 /usr/lib/python3.9/lib-dynload /home/jk/.local/lib/python3.9/site-packages /usr/local/lib/python3.9/dist-packages /usr/lib/python3/dist-packages /home/jk/.local/share/QGIS/QGIS3/profiles/default/python . /home/jk/admin/eigen/jobs/graw/solPot

Meanwhile, I have produced two vegetation grids from the point vector data set simply employing a vector-raster conversion using the fields for trunk and total height respectively. I applied them in the SEBE processor. It worked fine so fare. However, I am not sure whether the mere height of the trunk and the entire tree as pixel value are sufficient for further calculations. Again, thanks a lot for your effort. Cheers Jörg

nilswallenberg commented 1 year ago

Hi again,

I could not replicate your error with the data you provided before. Nevertheless, I saw that I made a small mistake, so if you are using other data it might be worth trying again with the new code.

Sorry for the inconvenience.

Cheers, Nils

jkblizzard commented 1 year ago

Dear Nils,

I am not sure whether you remember my little problem with the tree generator in August/September this year.

Already in September I have sent you a message via Github. However, I have never found this message back in the thread. I am not sure whether it reached you. Anyway, I just wanted to make sure letting you know that your effort is very much appreciated. SEBE works like a charm now including the tree generator.  Our company is about to submit a solar energy potential valuation for a developing area.

There is only one thing evoking a bit of additional workload: Energyyearwall.txt

We need these data for calculating and classifying the energy efficiency of buildings. In Germany there is this building standard "Passivhaus", basically meaning these buildings can be run with a heat pump and without additional heating and warm water supply through gas or oil. One of the parameters of this standard is the energy balance of building walls.

I understand that you do not use coordinates but rather relative pixel positions for this file for the sake of flexibility.  However, the columns of this file are blank space separated which means different numbers of spaces between the columns ones you have two digit and three digit values in one column. A regular spreadsheet calculation cannot dissolve this properly. I have written a little bash script as a workaround. However, it is rather static and has to be adjusted for new data sets especially if the building height is different.

I am not sure how much effort it is to generate an Energyyearwall.txt that is semicolon or comma separated. This would definitely enhance the data handling significantly, I believe. My aim is here, to generate a point data set with all energy values per horizontal meter wall in order to relate that to my building outlines.

In addition, I had problems with downloading ERA5 data. In my case just nothing happened even after six or more hours waiting time. However, I saw at least two threads in the github  issues section. I will check that first and open a new thread, if I cannot solve it.

Again, thanks a lot for your valuable work. I can also imagine that we might be able to contribute a little bit to your software once we are fully in flow with it.

Cheers

Jörg

nilswallenberg commented 1 year ago

Dear Jörg,

Happy to hear that SEBE and TreeGenerator works!

I remember your little problem and I am glad that we solved it.

My suggestion for Energyyearwall.txt is that you send us an issue labeled "Enhancement" and we will try to add an output of Energyyearwall as comma separated or similar as soon as possible.

Cheers, Nils