Bug report #20611

Data used and imported for calculation are again exported and created with the result of a calculation

Added by Olivier ATHIMON over 1 year ago. Updated about 1 year ago.

Status:Closed
Priority:High
Assignee:-
Category:Processing/GRASS
Affected QGIS version:3.5(master) Regression?:No
Operating System:Windows Easy fix?:No
Pull Request or Patch supplied:No Resolution:wontfix
Crashes QGIS or corrupts data:No Copied to github as #:28431

Description

For result in a directory, data used are created and exported again with the result... with processing/GRASS/raster r.mapcalc function and maybe more (functions)...

Thanks Jürgen Fischer because we can use GRASS in processing of QGIS 3.5.0 (maybe too for the next 3.4.2???) and Windows...

https://github.com/qgis/QGIS/commit/c13c97eeb2d2fb5c765d0b3e7ea7fad956eb243a
#20146

BUT WE HAVE A PROBLEM when we run the command because the data imported are exported again...

Example if i use this expression in processing/grass/raster > r.mapcalc:
My data : DEM (in a different dierctory of the result directory)
My expression : NEWDEM=DEM+10
Choose a directory for result : temporary (or a definitive place)

After calculation:
a file "NEWDEM.tif" is created in the result directory... but a (new) file "DEM.tif" is created too in this directory...
(i remind "DEM.tif" is the file used for calculation. It seems not necessary to export it again)

======
I think the problem is due to the fact that the data is imported into a temporary grass project with the r.in.gdal to do the calculation next.
Then the export is done from the result of the g.list function in this temporary grass project, result which lists the input data...

So, DEM is imported with r.in.gdal, <*any GRASS functions?*>, listed (not excluded) with g.list to prepare exportation and exported again (data calculated too) with r.out.gdal...
<r.mapcalc function is used between import and export>...

01_r.mapcalc_Data_used_and_imported_for_calculation.jpg (39.2 KB) Olivier ATHIMON, 2018-11-23 04:16 PM

02_r.mapcalc_expression_NewDEM_egal_DEM_plus_10.jpg (172 KB) Olivier ATHIMON, 2018-11-23 04:16 PM

03_r.mapcalc_algorithm_mkdir_r.in.gdal.jpg (353 KB) Olivier ATHIMON, 2018-11-23 04:16 PM

04_calculation_and_g_list.jpg (376 KB) Olivier ATHIMON, 2018-11-23 04:16 PM

05_end_export_result_and_export_too_data_used.jpg (348 KB) Olivier ATHIMON, 2018-11-23 04:16 PM

step_01_to_step20.zip - Pics from Step01 to Step20 (4.91 MB) Olivier ATHIMON, 2018-11-30 10:54 AM

History

#1 Updated by Giovanni Manghi over 1 year ago

  • Status changed from Open to Feedback

The plan is to remove r.mapcalc and replcae it with r.mapcalculator as soon as r.mapcalculator.py will be merged into GRASS.

r.mapcalc in QGIS has never really worked as expected.

#2 Updated by Jürgen Fischer over 1 year ago

  • Description updated (diff)

#3 Updated by Olivier ATHIMON over 1 year ago

Result of a new try with the last QGIS 3.5.0 code revision 23a4fb6e70 under Windows 7:
if we choose to create result in the same directory of a data input, we get the result of a formula, but data input is re-created (same datetime for data input and data created)... A message (Step03) gives the information...

After a formula f=DEM+30 which created a file "f.tif" (i have destroyed it in my directory before step01), i decided to do many tries:
- one to create a new file from a formula : g=DEM+100 (directory from data input to directory with result : pics from Step01 to Step05...)
- I also noticed that if QGIS is not closed and I run several calculations then each of these calculations is kept in memory and relaunched (so, from an old formula and an old file created with this formula and destroyed after... Step01 : i destroyed the file "f.tif" calculated before and QGIS created again the file (f.tif) from the old formula and created the new file with the new formula : g=DEM+100 from step02 to step05)
- step 06 to step09 : new formula (DEM1000=DEM+1000)
- step 10 : i destroy all files in my directory, except the file: DEM.tif...
- step 11 to step 15 with a new formula : DEM3000=DEM+3000... DEM.tif is overwritten, result file : DEM3000.tif is created... and all old destroyed files are created again : f.tif, g.tif and DEM1000.tif (not desired in the new formula)
- step 16 to step 20 : on the contrary, if I close QGIS, destroy old files (step 16) and launch a new formula then only the result of this formula is given with despite the overwritting of the input data (step17 to Step 20)

So, the old formula are kept (and relaunched with a new calculation) if we don't close QGIS session...

#4 Updated by Jürgen Fischer over 1 year ago

  • Assignee deleted (Jürgen Fischer)

#5 Updated by Giovanni Manghi about 1 year ago

  • Status changed from Feedback to Closed
  • Resolution set to wontfix

r.mapcalc is gone, r.mapcalculator is back.

Also available in: Atom PDF