I'm doing some batch analysis using SAGA's saga_cmd. Basicaly I have a lot of grids and shapes (mainly generated in SAGA by vectorization of raster classifiaction results).

Now I'm trying to make thing's the other way:

I want to run saga_cmd grid_gridding 0 to rasterize polygons but I need the resulting grid to be adjacent to every other raster I got right now (each one was used in some analysis and each one is in the same SAGA's grid system).

Because spatial extent of vector data isn't allways the same it is quite problematic to set it manually using [-USER_XMIN <str>] [-USER_XMAX <str>] [-USER_YMIN <str>] [-USER_YMAX <str>] [-USER_SIZE <str>] [-USER_FIT <str>] options.

When using SAGA's GUI there is a wizzard to do such thing (to choose Grid system when any grid is loaded in SAGA) but my question is how to do it using batch mode?

1 Answer 1


I was faced with the exact same problem some days ago. The only solution is to make a copy of the original grid and replace it. in that case you can use

-TARGET 1 -GRID_GRID result.sgrd

The result.sgrd file will be overwritten with your result, but will keep the boundaries that were present in the file you used.

I do agree that a better solution should be provided here. I think it should be possible to use -USER_GRID, but nowadays this is not possible.


  • Thank you a lot. The solution you've proposed worked like charm. I think it's good to mention that you need to make a copy of all 4 files related to SAGA's grid file (.sgrd, .mgrd, .sdat and .prj).
    – jzol
    Aug 28, 2014 at 21:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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