Hi All,

 

I need help to write a code in R to subtract two raster in SAGA.

 

I have "DEM_1_f.sgrd" and "DSM_1_f.sgrd" in SAGA format and I wish to
subtract (DSM_1_f.sgrd - DEM_1_f.sgrd) to obtain a new layer 

 

A part of the code is this:

 

#A# DEM - 1) Shapes to Grid

rsaga.get.usage("grid_gridding", 3)

rsaga.geoprocessor(lib="grid_gridding", module=3,
param=list(GRID="DEM_1.sgrd", INPUT="ground.shp", FIELD=0, LINE_TYPE=0,
USER_CELL_SIZE=dem.pixelsize, USER_X_EXTENT_MIN=ground@bbox[1,1],
USER_X_EXTENT_MAX=ground@bbox[1,2], USER_Y_EXTENT_MIN=ground@bbox[2,1],
USER_Y_EXTENT_MAX=ground@bbox[2,2]))

# filter the missing values using neighbours:

rsaga.geoprocessor(lib="grid_tools", module=7,
param=list(INPUT="DEM_1.sgrd", RESULT="DEM_1_f.sgrd", THRESHOLD=0.1))

 

#A# DSM - 2) Shapes to Grid

rsaga.get.usage("grid_gridding", 3)

rsaga.geoprocessor(lib="grid_gridding", module=3,
param=list(GRID="DSM_1.sgrd", INPUT="vegetation.shp", FIELD=0, LINE_TYPE=0,
USER_CELL_SIZE=dem.pixelsize, USER_X_EXTENT_MIN=vegetation@bbox[1,1],
USER_X_EXTENT_MAX=vegetation@bbox[1,2],
USER_Y_EXTENT_MIN=vegetation@bbox[2,1],
USER_Y_EXTENT_MAX=vegetation@bbox[2,2]))

# filter the missing values using neighbours:

rsaga.geoprocessor(lib="grid_tools", module=7,
param=list(INPUT="DSM_1.sgrd", RESULT="DSM_1_f.sgrd", THRESHOLD=0.1))

 

#DCM = DSM - DEM

 

Rsaga.geoprocessor(???)

 

Thanks for help 

 

Ale

 

PS: is there a link with a SAGA and R codes banks

 

 


	[[alternative HTML version deleted]]


