Skip to content

opening a grd file (Surfer)

4 messages · Anne GOARANT, Roger Bivand, Dylan Beaudette +1 more

#
Hello!

Does anyone know how to open a .grd file (surfer type file) with R (or 
convert this kind of file in ascii)? I tried using the RSAGA library but 
failed.
rsaga.geoprocessor("io_grid", 3, list( FILE = '10s70s0e150e.sgrd'))
This are bathymetry data from the GEBCO website.

Thanks
Anne
#
On Thu, 9 Oct 2008, Anne Goarant wrote:

            
The  GS7BG -- Golden Software Surfer 7 Binary Grid File Format, or GSBG -- 
Golden Software Binary Grid File Format drivers in the rgdal package ought 
to open these files for reading. They are in the CRAN Windows binary 
package.

Roger

  
    
#
On Thursday 09 October 2008, Anne Goarant wrote:
GDAL
#
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: