Skip to content
Prev 4321 / 29559 Next

opening a grd file (Surfer)

Hi Anne,

in case you are not mainly interested in importing the (potentially 
large) Surfer grid into R, but want to do raster calculations instead 
(e.g. using other SAGA modules), you might still be interested in the 
RSAGA way of converting it:

You didn't specify the file name of the SAGA output grid (GRID 
argument), the your FILE argument should point to the Surfer file (.grd).

Here a generic solution, starting with a Surfer grid temp.grd (which you 
can generate with io_grid module 2 if you don't have one):

library(RSAGA)
setwd("C:/here/is/my/tempfile")
# Get some help:
rsaga.get.usage("io_grid",3)
# Convert Surfer grid temp.grd to SAGA grid temp.sgrd:
rsaga.geoprocessor("io_grid",3,
     param = list(GRID = "temp.sgrd", FILE = "temp.grd"))
# Convert temp.sgrd to temp.asc with three decimal places:
rsaga.sgrd.to.esri("temp", prec = 3)
# Read grid (without header):
d = read.ascii.grid("temp", return.header = FALSE)
str(d) # only the grid data matrix
# Read grid (with header):
d = read.ascii.grid("temp")
str(d) # list: header, data matrix



Cheers
   Alex
Anne Goarant wrote: