1

I received data in .grd + .gri format, where the first one is a small text file and the second one (having the same name) is a binary file.

I am unable to open them in GRASS/QGIS. Any hint ? Missing library ? I tried to use Google but unfortunately "r" word is too small, and it ends to refer always to the r.* commands in GRASS...

This is the content of the .grd file:

[general] 
creator=R package 'raster' 
created= 2013-12-14 15:44:30 
[georeference] 
nrows= 134 
ncols= 143 
xmin= 56000 
ymin= 1613000 
xmax= 1200000 
ymax= 2685000 
projection= NA 
[data] 
datatype= FLT8S 
byteorder= little 
nbands= 5 
bandorder= BIL 
minvalue= 0:0:0:0:0 
maxvalue= 0.945:1:1:1:1 
nodatavalue= -1.7e+308 
[legend] 
legendtype=  
values=  
color=  
[description] 
layername= Value:Twin:Psum:pH:CN 
history=  

2 Answers 2

2

It is probably easier to write to GTiff, but if you want to use the grd/gri format, you can add a "virtual raster" header to it, such gdal will be able to process it.

library(raster)
r <- raster()
r[] <- 1:ncell(r)
r <- writeRaster(r, 'test.grd')
hdr(r, 'VRT')
# or simpler
r <- writeRaster(r, 'test.tif')

given that you already have a file, say 'test.grd'

library(raster)
r <- raster('test.grd')
hdr(r, 'VRT')
# or
r <- writeRaster(r, 'test.tif')

Now you should be able to open 'test.vrt' or 'test.tif' in GRASS (via gdal)

0
0

The raster package in R has the possibility to write a specific format using the function writeRaster. You can use for example GTiff. Here the short list of supported data formats. I assume you need a multiband format.

Type    Provider     extension  Multiband support
---------------------------------------------------------
raster  Native      .grd        Yes
ascii   ESRI Ascii  .asc        No
SAGA    SAGA GIS    .sdat       No
IDRISI  IDRISI      .rst        No
CDF     netCDF      .nc         Yes
GTiff   GeoTiff     .tif        Yes
ENVI    ENVI        .envi       Yes
EHdr    ESRI        .bil        Yes
HFA     Erdas       .img        Yes

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.