[R-sig-Geo] opening a grd file (Surfer)

Alexander Brenning brenning at uwaterloo.ca
Thu Oct 9 21:40:56 CEST 2008


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:
> 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
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> 
> 

-- 
Alexander Brenning
brenning at uwaterloo.ca - T +1-519-888-4567 ext 35783
Department of Geography and Environmental Management
University of Waterloo
200 University Ave. W - Waterloo, ON - Canada N2L 3G1
http://www.fes.uwaterloo.ca/geography/faculty/brenning/




More information about the R-sig-Geo mailing list