[R-sig-Geo] Create raster data set using rgdal
Lukas Lehnert
lukaslehnert at googlemail.com
Sat Jun 1 07:41:34 CEST 2013
Thank you for the reply. I made a stupid mistake in the last post. I meant
specifying number of bands, rows and columns in the newly created image (and
not omitting). I know the raster package and the creation options. However I
need to use rgdal and not the raster package for that purpose.
Best regards
Lukas
Am Freitag, 31. Mai 2013, 17:29:55 schrieb Barry Rowlingson:
> 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