```r
writeRaster(dtm,"gis_data/saga_dtm.sgrd",format="SAGA", overwrite=TRUE)
writeRaster(dsm,"gis_data/saga_dsm.sgrd",format="SAGA", overwrite=TRUE)
system ("saga_cmd ta_lighting 2 -GRD_DEM gis_data/saga_dtm.sgrd  -DAY '13/10/17' -GRD_DIRECT    gis_data/saga_sol")

system ("saga_cmd ta_hydrology 15 -DEM gis_data/saga_dtm.sgrd  -TWI   gis_data/saga_TWI")

sol<-raster("gis_data/saga_sol.sdat")
twi<-raster("gis_data/saga_TWI.sdat")

sol@crs<-dtm@crs
twi@crs<-dtm@crs

writeRaster(sol,"gis_data/sol.tif",format="GTiff", overwrite=TRUE)
writeRaster(twi,"gis_data/twi.tif",format="GTiff", overwrite=TRUE)

sol<-raster("gis_data/sol.tif")
twi<-raster("gis_data/twi.tif")

system("rm gis_data/saga*")
```