1

I'm trying to script a reclassification using SAGA Grid_Tools-Reclassify Grid Values tool but I'm having the error: Reclassify Grid Values: could not initialize data objects.

I've tried different things:

  1. With the SAGA GUI: works but I need to script it so it is not practical
  2. With rqgis: Doesn't give me an error, but doesn't produce any files
  3. With RSAGA: Gives me the could not initialize data objectserror
  4. Directly in the Windows system console: Gives me the could not initialize data objectserror again.

I'll focus my question on the last try as it's a more direct connection to SAGA. BTW, I'm using SAGA 2.3.2 64 bits on windows Server 2012 R2.

My system call is:

"C:\OSGeo4W64\apps\saga\saga_cmd.exe" -f=q grid_tools 15 -INPUT "C:\temp\depth_D500.tif" -METHOD "2" -RESULT "C:\temp\bldg_vuln_curves_SAGA_D500.tif" -RETAB "C:\temp\bldg_vuln_curves_SAGA.csv" -TOPERATOR "0"

And the result:

_____________________________________________

   #####   ##   #####    ##
  ###     ###  ##       ###
   ###   # ## ##  #### # ##
    ### ##### ##    # #####
 ##### #   ##  ##### #   ##
_____________________________________________

_____________________________________________
library path:   C:\OSGeo4W64\apps\saga\modules\grid_tools.dll
library name:   Grid - Tools
tool name   :   Reclassify Grid Values
author      :   Copyrights (c) 2005 by Volker Wichmann
_____________________________________________

Load table: C:\temp\bldg_vuln_curves_SAGA.csv...
okay


Parameters


Grids: No objects
Files: C:\temp\depth_D500.tif
Transformation: yes
Interpolation: B-Spline Interpolation


loading: C:\temp\depth_D500.tif



Driver: GTiff

Bands: 1

Rows: 3600

Columns: 3600



Transformation:

  x' = -89.000000 + x * 0.000278 + y * 0.000000

  y' = 55.000000 + x * 0.000000 + y * -0.000278


loading band [1/1]
Reclassify Grid Values: could not initialize data objects
Error: executing tool [Reclassify Grid Values]

It seems like SAGA can read the input raster and the classification table without any problems, but he can't write the files or something. I suspected an administrative right issue but I have all the rights on that folder. I also have plenty of storage place so that's not the problem either. I've already had problem with SAGA writing tif files, so I've also tried changing the RESULT files to .sgrd and .sdat with no luck.

My files can be downloaded here:

raster

table

Any idea what the problem is?

Note: I've had better luck making the grass r.reclass tool work, however it doesn't handle well the floating values so it's not an option.

  • Try to load the Tool thru the Gui, then "Save to Script File. Most of the parameters have an "=" between param name and value. Your command line parameters do not. – klewis Aug 30 '17 at 18:43
1

I've finally fixed it. I think there where multiple problems which made more complicated finding a solution.

First error, SAGA command requires a .sgrd file. You CANNOT give it a .tif. This happens only if you script SAGA, has using tif file in the GUI works fine. I had that problem before and I had tried this solution here, but it didn't help probably because I had another problem.

The other problem is more obscure. I didn't find it exactly but I think the -f=q is causing problems sometimes. If it's there you need the = sign, if it's not there you don't (thanks to @klewis to help me figure it out). Very weird... Anyway, here is the command that works

"C:\OSGeo4W64\apps\saga\saga_cmd.exe" grid_tools 15 -INPUT C:\Users\Bastien\Pictures\depth_D500.sgrd -RESULT C:\Users\Bastien\Pictures\depth_D500SAGA.sgrd -METHOD "2" -RETAB C:\temp\bldg_vuln_curves_SAGA.csv -TOPERATOR 0 

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.