Skip to content
This repository has been archived by the owner on Apr 20, 2020. It is now read-only.

Problems with parameters in "gdalogr:rastercalculator" #79

Closed
BastienFR opened this issue Aug 31, 2017 · 2 comments
Closed

Problems with parameters in "gdalogr:rastercalculator" #79

BastienFR opened this issue Aug 31, 2017 · 2 comments

Comments

@BastienFR
Copy link

I've found a weird behaviour which is causing some issue. When I run a algorithm, it hardcodes parameters making the function get_args_man function useless.

library(RQGIS)
monqgis <- set_env("C:\\OSGeo4W64")
 
###  first run:
params <- get_args_man(alg = "gdalogr:rastercalculator", qgis_env = monqgis)
params$FORMULA <- "A+1"
params$INPUT_A <- "c:/temp/depth_D500.tif"
params$OUTPUT <- "c:/temp/test.tif"
run_qgis(alg = "gdalogr:rastercalculator", params=params, qgis_env = monqgis)
$OUTPUT
[1] "c:/temp/test.tif"

get_args_man(alg = "gdalogr:rastercalculator", qgis_env = monqgis)
$INPUT_A
[1] "\"c:/temp/depth_D500.tif\""

$BAND_A
[1] "\"\"1\"\""

$INPUT_B
[1] "\"None\""

$BAND_B
[1] "\"\"1\"\""

$INPUT_C
[1] "\"None\""

$BAND_C
[1] "\"\"1\"\""

$INPUT_D
[1] "\"None\""

$BAND_D
[1] "\"\"1\"\""

$INPUT_E
[1] "\"None\""

$BAND_E
[1] "\"\"1\"\""

$INPUT_F
[1] "\"None\""

$BAND_F
[1] "\"\"1\"\""

$FORMULA
[1] "\"A+1\""

$NO_DATA
[1] "\"\"\"\""

$RTYPE
[1] "0"

$EXTRA
[1] "\"\"\"\""

$OUTPUT
[1] "None"

 ###  second run in same session:
params <- get_args_man(alg = "gdalogr:rastercalculator", qgis_env = monqgis)
params$FORMULA <- "A+1"
params$INPUT_A <- "c:/temp/depth_D500.tif"
params$OUTPUT <- "c:/temp/test.tif"
run_qgis(alg = "gdalogr:rastercalculator", params=params, qgis_env = monqgis)
$OUTPUT
[1] "c:/temp/test.tif"

get_args_man(alg = "gdalogr:rastercalculator", qgis_env = monqgis)
$INPUT_A
[1] "\"c:/temp/depth_D500.tif\""

$BAND_A
[1] "\"\"\"1\"\"\""

$INPUT_B
[1] "\"'None'\""

$BAND_B
[1] "\"\"\"1\"\"\""

$INPUT_C
[1] "\"'None'\""

$BAND_C
[1] "\"\"\"1\"\"\""

$INPUT_D
[1] "\"'None'\""

$BAND_D
[1] "\"\"\"1\"\"\""

$INPUT_E
[1] "\"'None'\""

$BAND_E
[1] "\"\"\"1\"\"\""

$INPUT_F
[1] "\"'None'\""

$BAND_F
[1] "\"\"\"1\"\"\""

$FORMULA
[1] "\"A+1\""

$NO_DATA
[1] "\"\"\"\"\"\""

$RTYPE
[1] "0"

$EXTRA
[1] "\"\"\"\"\"\""

$OUTPUT
[1] "None"

 
###  third run in same session:
params <- get_args_man(alg = "gdalogr:rastercalculator", qgis_env = monqgis)
params$FORMULA <- "A+1"
params$INPUT_A <- "c:/temp/depth_D500.tif"
params$OUTPUT <- "c:/temp/test.tif"
run_qgis(alg = "gdalogr:rastercalculator", params=params, qgis_env = monqgis)
Error in run_qgis(alg = "gdalogr:rastercalculator", params = params, qgis_env = monqgis) : 
  Unable to execute algorithm
Wrong parameter value: None

 
get_args_man(alg = "gdalogr:rastercalculator", qgis_env = monqgis)
$INPUT_A
[1] "\"c:/temp/depth_D500.tif\""

$BAND_A
[1] "\"\"\"\"1\"\"\"\""

$INPUT_B
[1] "\"''None''\""

$BAND_B
[1] "\"\"\"\"1\"\"\"\""

$INPUT_C
[1] "\"''None''\""

$BAND_C
[1] "\"\"\"\"1\"\"\"\""

$INPUT_D
[1] "\"''None''\""

$BAND_D
[1] "\"\"\"\"1\"\"\"\""

$INPUT_E
[1] "\"''None''\""

$BAND_E
[1] "\"\"\"\"1\"\"\"\""

$INPUT_F
[1] "\"''None''\""

$BAND_F
[1] "\"\"\"\"1\"\"\"\""

$FORMULA
[1] "\"A+1\""

$NO_DATA
[1] "\"\"\"\"\"\"\"\""

$RTYPE
[1] "0"

$EXTRA
[1] "\"\"\"\"\"\"\"\""

$OUTPUT
[1] "None"

> 

You can see that for all unused arguments, there is some kind of arguments buildup... This is a weird and problematic behaviour if not a bug.

Thanks
Bastien Ferland-Raymond

@jannes-m
Copy link
Collaborator

jannes-m commented Aug 31, 2017

Thanks, you are right, there is something wrong, will have a look at it during the next week!

Actually, it's not get_args_man which is causing trouble but pass_args, I guess...

@jannes-m
Copy link
Collaborator

jannes-m commented Sep 4, 2017

Commit 29fb26a fixes the bug you detected, thanks for letting us know! Now everything should work as expected, give it a try (for this to work you need, of course, to install the RQGIS developer version):

data("dem", package = "RQGIS")
alg = "gdalogr:rastercalculator"
out = run_qgis(alg = alg, 
               FORMULA = "A+0.1",
               INPUT_A = dem / 1000, OUTPUT = "test.tif", load_output = TRUE)
get_args_man(alg)

@jannes-m jannes-m closed this as completed Sep 4, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants