Closed matthiasdemuzere closed 7 months ago
Perhaps just to clarify: it is not a problem with the /tmp/*_vector.GeoJSON files. When I use the default, they are correctly written to the tmp/ folder.
It seems to be a problem with the temporary files created within the Algorithm ...
ing a proper path in:
veg_vect = processing.run("native:pixelstopolygons", {'INPUT_RASTER':veg_dsm_rounded, 'RASTER_BAND':1, 'FIELD_NAME':'VALUE', # 'OUTPUT':'TEMPORARY_OUTPUT'})["OUTPUT"] 'OUTPUT':'/mnt/SSD2TB/data/UMEP/UROCK/Annedal_EPSG3006/tmp/tmp_vect.tif'})["OUTPUT"]
Hi @matthiasdemuzere thanks for reporting and investigating.
Is is the same error if you replace 'TEMPORARY_OUTPUT' by a file in the temporary output (such as '/tmp/test.tif') or is it the same problem (does it come from the directory automatically created by QGIS or by saving anything in the temp folder) ?
It works when defining my own temp file, eg. /tmp/tmp.tif
.
But not when using the TEMPORARY_OUTPUT
.
As far as I can see, this behaviour occurs in the following algorithms:
This is confirmed when launching these separately in QGIS, eg. for rastercalculator:
Saving as temporary file:
Algorithm started at: 2024-04-15T09:51:09
Algorithm 'Raster calculator' starting…
Input parameters:
{ 'BAND_A' : 1, 'BAND_B' : None, 'BAND_C' : None, 'BAND_D' : None, 'BAND_E' : None, 'BAND_F' : None, 'EXTENT_OPT' : 0, 'EXTRA' : '', 'FORMULA' : '(A > B) * (A - B) + (A <= B) * 0', 'INPUT_A' : '/mnt/SSD2TB/data/UMEP/UROCK/Annedal_EPSG3006/dsm.tif', 'INPUT_B' : '/mnt/SSD2TB/data/UMEP/UROCK/Annedal_EPSG3006/dem.tif', 'INPUT_C' : None, 'INPUT_D' : None, 'INPUT_E' : None, 'INPUT_F' : None, 'NO_DATA' : None, 'OPTIONS' : '', 'OUTPUT' : 'TEMPORARY_OUTPUT', 'PROJWIN' : None, 'RTYPE' : 5 }
GDAL command:
gdal_calc.py --overwrite --calc "(A > B) * (A - B) + (A <= B) * 0" --format Leveller --type Float32 -A /mnt/SSD2TB/data/UMEP/UROCK/Annedal_EPSG3006/dsm.tif --A_band 1 -B /mnt/SSD2TB/data/UMEP/UROCK/Annedal_EPSG3006/dem.tif --outfile /tmp/processing_rolgHG/1c8e70e9d4e64635a5bab0185472df79/OUTPUT.ter
GDAL command output:
Traceback (most recent call last):
File "/home/matthias/micromamba/envs/qgis-env/lib/python3.11/site-packages/osgeo_utils/auxiliary/gdal_argparse.py", line 226, in main
self.doit(**kwargs)
File "/home/matthias/micromamba/envs/qgis-env/lib/python3.11/site-packages/osgeo_utils/gdal_calc.py", line 887, in doit
return Calc(**kwargs)
^^^^^^^^^^^^^^
File "/home/matthias/micromamba/envs/qgis-env/lib/python3.11/site-packages/osgeo_utils/gdal_calc.py", line 424, in Calc
myOut = myOutDrv.Create(
^^^^^^^^^^^^^^^^
File "/home/matthias/micromamba/envs/qgis-env/lib/python3.11/site-packages/osgeo/gdal.py", line 3192, in Create
return _gdal.Driver_Create(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: MINUSERPIXELVALUE must be specified.
Process returned error code 1
Execution completed in 0.32 seconds
Results:
{'OUTPUT': '/tmp/processing_rolgHG/1c8e70e9d4e64635a5bab0185472df79/OUTPUT.ter'}
Loading resulting layers
The following layers were not correctly generated.
• /tmp/processing_rolgHG/1c8e70e9d4e64635a5bab0185472df79/OUTPUT.ter
You can check the 'Log Messages Panel' in QGIS main window to find more information about the execution of the algorithm.
Defining an output file
Algorithm 'Raster calculator' starting…
Input parameters:
{ 'BAND_A' : 1, 'BAND_B' : None, 'BAND_C' : None, 'BAND_D' : None, 'BAND_E' : None, 'BAND_F' : None, 'EXTENT_OPT' : 0, 'EXTRA' : '', 'FORMULA' : '(A > B) * (A - B) + (A <= B) * 0', 'INPUT_A' : '/mnt/SSD2TB/data/UMEP/UROCK/Annedal_EPSG3006/dsm.tif', 'INPUT_B' : '/mnt/SSD2TB/data/UMEP/UROCK/Annedal_EPSG3006/dem.tif', 'INPUT_C' : None, 'INPUT_D' : None, 'INPUT_E' : None, 'INPUT_F' : None, 'NO_DATA' : None, 'OPTIONS' : '', 'OUTPUT' : '/home/matthias/.local/share/QGIS/QGIS3/profiles/default/processing/outputs/test.tif', 'PROJWIN' : None, 'RTYPE' : 5 }
GDAL command:
gdal_calc.py --overwrite --calc "(A > B) * (A - B) + (A <= B) * 0" --format GTiff --type Float32 -A /mnt/SSD2TB/data/UMEP/UROCK/Annedal_EPSG3006/dsm.tif --A_band 1 -B /mnt/SSD2TB/data/UMEP/UROCK/Annedal_EPSG3006/dem.tif --outfile /home/matthias/.local/share/QGIS/QGIS3/profiles/default/processing/outputs/test.tif
GDAL command output:
0...10...20...30...40...50...60...70...80...90...100 - done.
Process completed successfully
Execution completed in 0.38 seconds
Results:
{'OUTPUT': '/home/matthias/.local/share/QGIS/QGIS3/profiles/default/processing/outputs/test.tif'}
PS. Note on the side:
Is it intended to do roundrastervalues
twice on the CDSM? As now done in line 331 and 338?
@matthiasdemuzere , one thing that might work is to change default filetype for raster. In WGIS, go to Settings/Options/Processing/General and make sure that you are using .tif as Default output raster layer extension.
@biglimp Thanks, this seems work? At least when testing on the rastercalulcator directly. I'll set everything to default again in urock_prepare_algorithm.py
and will try again.
@matthiasdemuzere , one thing that might work is to change default filetype for raster. In WGIS, go to Settings/Options/Processing/General and make sure that you are using .tif as Default output raster layer extension.
Great, this solution worked for me! Thanks again.
@matthiasdemuzere , one thing that might work is to change default filetype for raster. In WGIS, go to Settings/Options/Processing/General and make sure that you are using .tif as Default output raster layer extension.
Great, this solution worked for me! Thanks again.
Great. @j3r3m1 , we should communicate this to other users, to use .tif and .shp as standard.
Great. @j3r3m1 , we should communicate this to other users, to use .tif and .shp as standard.
It can be in the manual (for example a new 2.2 section called "Recommended default QGIS output files" - https://umep-docs.readthedocs.io/en/latest/Getting_Started.html#getting-started) and also in the note of some of the plugins that may cause the problem (e.g.: https://umep-docs.readthedocs.io/projects/tutorial/en/latest/Tutorials/IntroductionToURock.html) ?
It can also be added in the FAQ...
It can also be added in the FAQ...
Yes. I can add it in FAQ
Do I add it also in the getting started and in the note of some of the models or FAQ is sufficient ?
Do I add it also in the getting started and in the note of some of the models or FAQ is sufficient ?
Yes, maybe good to add in getting started also.
Yes, maybe good to add in getting started also.
I do that right away
Hi @j3r3m1, all,
I am currently trying the URock tutorial, using default settings and sample data.
When doing so, I get a rather vague error:
I checked the
urock_prepare_algorihm.py
a bit, and the issue seems to arise atbuild_dsm = processing.run("gdal:rastercalculator", ...
First I test the raster calculation directly from gdal, used within the same environment as qgis:
gdal_calc.py -A dsm.tif -B dem.tif --outfile=dsm-dem.tif --calc="(A > B) * (A - B) + (A <= B) * 0"
That works.After some testing I found out that writing to tmp/ dir is problematic? The file is created on my system, but it is empty. When changing
'OUTPUT':'TEMPORARY_OUTPUT'
to an actual directory, eg.'OUTPUT':'SOME/DIR/tmp.tif'
That seems to work. Although then another error dissapears (at least when using the python console):
Though I don't think this one is relevant at the moment.
In any case, when setting a non-tmp directory to when creating build_dsm, and running the GUI approach again,
build_vector.GeoJSON
is correctly created.veg_vector.GeoJSON
not yet:Also setting a proper path in:
Seems to work for me.
So ... long story short: seems some of the processes are struggling to create the files in the
/tmp/
directory? At least on my ubuntu 22.04 system?I am not sure why that is, since this directory is accessible and writeable ... Any ideas?