2

I am using QGIS 2.6 Brighton.

I am trying to run a Gavrilovic model in the modeller in QGIS. FYI: Gavrilovic model is a set of Imperical equations for sediment yield analysis.

The equations are as follows:

W = T * h * [pi] * sqrt(z^3)      ..1
T = sqrt ( t/10 + 0.1 )           ..2
z = x * y * ( [phi] + sqrt (J) )  ..3

What I have in QGIS ?

I have raster layers of t, h, x, y, [phi], J.

What do I need to do ?

  1. Calculate z as in equation 3; I have all required variables as rasters.
  2. Calculate T from t as in equation 2.
  3. Calculate W.
  4. Now I need to change the values of t and h rasters. Lets say for example, the existing values of t need to be first changed by -15%, -10%, -5%, +5%, +10%, +15%. And run the equations again to evaluate what will be the changes in W with respect to change in t. Similar for h.
  5. Again I need to evaluate W for -15%, -10%, -5%, +5%, +10%, +15% change in h for each change in t.

To elaborate point no. 4 and 5.
Let us assume each raster has 4 cells. And these be the initial values of t and h.

t =  10,  12,  15, 12
h = 110, 100, 140, 90

Now for the sensitivity test, I need the values of t changed by -15%, -10% , -5%, +5%, +10%, +15%. And similar for h. 6 new t rasters will be created according to the percentage change and the values will be as follows for t.

col A      B      C      D     E     F       G
initial_t -15%   -10%   -5%   +5%    +10%    +15%

   10      8.5     9    9.5   10.5   11      11.5
   12      1.7    1.8   1.9   2.1    2.2     2.3
   15      12.75  13.5  14.25 15.75  16.5    17.25
   12      10.2   10.8  11.4  12.6   13.2    13.8

Similarly 6 new h rasters will be created, as follows:

col  1       2       3        4        5      6      7
initial_h   -15%    -10%     -5%      +5%    +10%   +15%

110         93.5    99       104.5    115.5  121    126.5
100         85      90          95      105  110    115
140         119     126        133      147  154    161
 90         76.5    81        85.5     94.5   99    103.5

Now, I need to run equations 1 to 3 taking t and h in following fashion:

for p = col A to col G {
 for q = col 1 to col 7 {
     run equation 3
     run equation 2
     run equation 1   
 }
}

Note: I've heard changing values of raster and running this algorithm is easier in graphics modeller.
If not, I can create those 6 new rasters for t and h myself. I can use R for that. However if it can be done in QGIS (other than using raster calculator) it would be great if you can share the idea.

I need someone to tell me how can I set up a Graphics modeller 
and perform  these operations.   

I am not familiar with python but I can find my way writing the code.

  • 1
    Sorry, but to me it is not obvious, what your question is. Could you please clarify? – Erik Apr 10 '18 at 7:10
  • 2
    2.6 is very old and I'd suggest you upgrade first. – Spacedman Apr 10 '18 at 7:10
  • You probably need to write some python code to do your sensitivity analysis. This will depend on how you plan to "edit" your rasters to test the sensitivity. Me, I'd do it in R. – Spacedman Apr 10 '18 at 7:12
  • 1
    guys, instead of putting the question on hold, please comment and ask for clarifications. you are just forbidding someone else to answer the question if they understood it or after clarification. – anup Apr 10 '18 at 11:35
  • 1
    You need to give more information about how you are planning to change your inputs for the sensitivity test - do you want all that automated? Can you program in python? Have you tried? You might even be better off not using QGIS and doing it in plain python or using the GDAL utilities such as gdal_calc gdal.org/gdal_calc.html - what scripting skills do you have? – Spacedman Apr 10 '18 at 13:15
3

I'd script this using gdal_calc.py:

Starting with six tiffs:

$ ls *tif
h.tif  j.tif  phi.tif  t.tif  x.tif  y.tif

This script:

# clear intermediates and output
rm -f z.tif bigt.tif W.tif

# z = x * y * ( [phi] + sqrt (J) )  ..3
gdal_calc.py --calc='X*Y*(P+sqrt(J))' -X x.tif -Y y.tif -P phi.tif -J j.tif --outfile=z.tif

# T = sqrt ( t/10 + 0.1 )           ..2
gdal_calc.py --calc='sqrt(T/10 + 0.1)' -T t.tif --outfile=bigt.tif

# W = T * h * [phi] * sqrt(z^3)      ..1
gdal_calc.py --calc='T * H * P * sqrt(Z**3)' -T bigt.tif -H h.tif -P phi.tif -Z z.tif --outfile=W.tif

produces W.tif which (I think) has the final quantity you are computing, alongside the intermediate rasters as well.

Once you've got that running as a shell script at the command line, you can script the process of changing your inputs and collecting the outputs, but the whole thing is a big ask and probably too broad for now, especially if you can do it in R anyway.

  • thank you for the response ! looking from the code, it is just summarizing the raster calculator (and of course making it easier). But I still would have to edit input raster filename every time I need to change input. What I was hoping was if there was a way to automate the process of selection of raster or may be change inputs here. I thought it was possible with graphics modeller. since nobody is suggesting anything about graphics modeller I guess, I might have over expected from graphics modeller and my thought of automating everything was probably too vague. ++ – anup Apr 12 '18 at 5:09
  • Besides, I've figured out a way to do what I want, all in R. I will answer to my own question later. Thank you for your time and response btw. It would certainly help had I not figured out my way. – anup Apr 12 '18 at 5:10
  • 1
    I'd do something in the modeller but its currently broken on my laptop QGIS - some weird problem with Qt is breaking the layout of the dialogs... – Spacedman Apr 12 '18 at 7:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.