[R-sig-Geo] Problems with writeGDAL (gridded function)

Pierre Roudier pierre.roudier at gmail.com
Mon Aug 9 01:57:58 CEST 2010


Hi Ana,

Your post is missing some details, like your sessionInfo() output, and
the way you are reading your data.

>From what I understand, you are using the (excellent) raster package
to read your data, that's why the class of your data is "RasterLayer".

The writeGDAL() function from the rgdal package is not able to cope
with that class AFAIK. You have to translate your object from the
RasterLayer class to an sp class (typically SpatialPixelsDataFrame for
raster data), as follows:

library(raster)
library(rgdal)
data(drg) # Loading some sample data
class(drg) # drg is a "RasterLayer" object
writeGDAL(drg, "foo.tif", drivername="GTiff") # You get an error
because writeGDAL can't  deal with RasterLayer objects
drg.sp <- as(drg, "SpatialPixelsDataFrame") # Converting the
RasterLayer object to a SpatialPixelsDataFrame object
class(drg.sp)
writeGDAL(drg.sp, "foo.tif", drivername="GTiff") # This should work

Hope this help,

Pierre

2010/8/9 rras terr <rrasterr at gmail.com>:
> I all,
>
> I am having problems in exporting data using writeGDAL & create2GDAL:
>
> Error in function (classes, fdef, mtable)  :
> unable to find an inherited method for function "gridded", for signature
> "RasterLayer"
> Calls: writeGDAL -> create2GDAL -> stopifnot -> gridded -> <Anonymous>
>
> --
> rgdal version: 0.6-28
> --
>
> Any suggestion?
>
> Thanks in advance,
> Ana
>
>        [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>



More information about the R-sig-Geo mailing list