0

I'm working with an asc file in R and trying to run it through some GIS processing on a script that was written by someone else. The current chunk of code I'm working on is

asc <- (raster(inputRas))

asc.extent <- extent(asc)

head <- read.ascii.grid.header(inputRas)

writeRaster(asc, "outputRas", format="SAGA", overwrite=TRUE)

which works until the last line. It's failing here because my raster is in rectangular coordinates, which SAGA doesn't like. I've spent a lot of time googling and trying different functions, but nothing has worked that didn't cause other problems down the line. I considered using projectRaster() for a while because the resolution can be changed within it, but I don't actually want to change the projection. Any help would be appreciated, thanks.

1 Answers1

0

Instead of raster::projectRaster, you can use raster::resample

Robert Hijmans
  • 40,301
  • 4
  • 55
  • 63
  • I haven't been able to figure out how to redefine the resolution within the resample() function. It seems as though I need another raster layer with the parameters (e.g. square pixels of the right size) to act as a "template" but I don't have another raster with those specifications. Am I missing something? – Marika Feduschak Oct 03 '20 at 19:18
  • You can create one using the input data and the `res` method – Robert Hijmans Oct 04 '20 at 15:44