My problem: I have two DEMs, one rectangular and containing the other. Both are given in grid formats and the outer one has gridsize 50m, the inner one 10m. I want to 'embed' the smaller one in the larger one, merge them and export the whole merged grid as .xyz files with grid size 50m.
All this I can do manually in SAGA-GIS, using the following steps:
- Import the outer grid using the module "
io_grid
" – "Import Surfer Grid" (ID 3) - Import the inner grid using "
io_gdal
" – "GDAL: Import Raster" (ID 0) - Use the splendid mosaicking tool "
grid_tools
" – "Mosaicking" (ID 3) - Export the resulting grid using "
io_grid
" – "Export Grid to XYZ" (ID 5)
Now I want to automate all this using saga_cmd
. I managed to turn the first two steps into a script quite easily:
io_grid 3 -FILE=G:\path_to_file\foo.grd -NODATA=0 -NODATA_VAL=-99999.000000
io_gdal 0 -FILES=G:\path_to_file\bar.adf
Step 3 is tricky though. The SAGA-generated example for the module grid_tools 3
suggests to do something like that:
grid_tools "Mosaicking" -GRIDS=memory;memory -TYPE=7 -INTERPOL=0 -OVERLAP=1 -BLEND_DIST=10.000000 -TARGET=1 -USER_XMIN=0.000000 -USER_XMAX=0.000000 -USER_YMIN=0.000000 -USER_YMAX=0.000000 -USER_SIZE=1.000000 -USER_COLS=0 -USER_ROWS=0 -USER_GRID=NULL -GRID_GRID=
In the SAGA GUI, I simply choose the input grids manually in this step (with a drop-down menu – interactively). But it seems to me that I have to name the imported grids, which I did not do in the script. But how do name them. And how can I tell grid_tools "Mosaicking"
to use the two before-loaded grids?
Best Answer
Typing
saga_cmd io_grid 3
and cutting the header:you will notice the
-GRID
optional parameter. It allows to specify the name of the SAGA grid to store on your disk and not in memory. The concept is quite the same forsaga_cmd io_gdal 0
.So you need to adapt your commands, storing on your disk every output grid in SDAT (SAGA GIS Binary Grid File Format) format using the
.sgrd
extension.Finally, a useful remark from How to create a python script for saga: