[R-sig-Geo] Attach metadata to raster object

Josh O'Brien joshmobrien at gmail.com
Fri Dec 6 18:39:19 CET 2013


Bastien Ferland-Raymond wrote
> Hello Étienne,
> 
> I'm a little disappointed nobody replied to your question, as this is
> something I'm also interested in.  The slot you are proposing to add
> metadata to raster* object could also be useful to allow categorical
> raster, something the raster package do not do.  I think it would be great
> to be able to use integer in the rasters values and than add in the
> metadata slot the key that specify the factors values (ex: 1=private land,
> 2=public land, etc.).  Having all that within the same R object would be a
> must.
> 
> Bastien

Hi Bastien,

The raster package**does** support categorical rasters, to some extent. Type
?ratify for the relevant documentation, and for a quick taste of what's
possible, try:

    library(raster)
    library(rasterVis)  ## For its levelplot method for rasters
    example(ratify)    ## Creates a categorical raster with three veg types
    levelpot(ratify)    ## Plots them with an categorical legend
    levels(x)[[1]]      ## Have a look at the layer's "RAT" (Raster
Attribute Table)

HTH,

Josh



--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/Attach-metadata-to-raster-object-tp7585254p7585294.html
Sent from the R-sig-geo mailing list archive at Nabble.com.



More information about the R-sig-Geo mailing list