[R-sig-Geo] Create raster data set using rgdal
Barry Rowlingson
b.rowlingson at lancaster.ac.uk
Fri May 31 18:29:55 CEST 2013
On Fri, May 31, 2013 at 3:19 PM, Lukas Lehnert
<lukaslehnert at googlemail.com> wrote:
> Dear all,
>
> is there any recommended way to create a new raster file (if possible of Envi-
> format) using rgdal by simply omitting the number of bands, columns, rows and
> the datatype? How can I fill that file with new data?
Did you mean "omitting" (leaving out)? Or did you mean "specifying"?
Hard to know what's left if you omit all that information!
I'd use the raster package. rgdal and raster don't really let you
"fill in" existing files, you have to read them in and write them out
into R objects.
Here's how to create an empty raster object with an extent, number of
rows and columns, then put some random numbers in it and plot. See
?writeRaster for how to create your Envi output file.
> r = raster(nrows=180, ncols=360, xmn=-180, xmx=180, ymn=-90, ymx=90)
> r
class : RasterLayer
dimensions : 180, 360, 64800 (nrow, ncol, ncell)
resolution : 1, 1 (x, y)
extent : -180, 180, -90, 90 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84
> r[]=runif(64800)
> plot(r)
> ?writeRaster
Barry
More information about the R-sig-Geo
mailing list