As I am trying to add georeferenced tif-files to my ggplots in R, I have encountered a seemingly weird problem with slots: After loading the raster file using raster()
I can't reach its colortable
-slot:
>>Grab the example tif-file<<:
raster1 <- raster(paste(workingDir, "/HUEK200_Durchlaessigkeit001_proj001.tif", sep="", collapse=""))
raster1@colortable #or
slot(raster1, "colortable")
The two last lines shoudl work equally but result both in the error message:
Error in slot(raster1, "colortable") :
no slot of name "colortable" for this object of class "RasterLayer"
This is confusing because a small glimpse into the attributes via attributes(raster1)
clearly lists exactly that slot:
Slot "colortable":
[1] "#FFFFFF" "#000000" "#B49ED7" "#9B7DCF" "#9EAAD7" "#B2BEEB" "#B4EBB4"
[8] "#F5E1B5" "#CCB792" "#B9A08C" "#0070FF" "#0000C8" "#F8F8F8" "#DBF5FF"
[15] "#B14D00" "#000000" "#000000" "#000000" "#000000" "#000000" "#000000"
[22] "#000000" "#000000" "#000000" "#000000" "#000000" "#000000" "#000000"
[29] "#000000" "#000000" "#000000" "#000000" "#000000" "#000000" "#000000"
[36] "#000000" "#000000" "#000000" "#000000" "#000000" "#000000" "#000000"
[43] "#000000" "#000000" "#000000" "#000000" "#000000" "#000000" "#000000"
[50] "#000000" "#000000" "#000000" "#000000" "#000000" "#000000" "#000000"
[57] "#000000" "#000000" "#000000" "#000000" "#000000" "#000000" "#000000"
[64] "#000000" "#000000" "#000000" "#000000" "#000000" "#000000" "#000000"
[71] "#000000" "#000000" "#000000" "#000000" "#000000" "#000000" "#000000"
[78] "#000000" "#000000" "#000000" "#000000" "#000000" "#000000" "#000000"
[85] "#000000" "#000000" "#000000" "#000000" "#000000" "#000000" "#000000"
[92] "#000000" "#000000" "#000000" "#000000" "#000000" "#000000" "#000000"
[99] "#000000" "#000000" "#000000" "#000000" "#000000" "#000000" "#000000"
[106] "#000000" "#000000" "#000000" "#000000" "#000000" "#000000" "#000000"
[113] "#000000" "#000000" "#000000" "#000000" "#000000" "#000000" "#000000"
[120] "#000000" "#000000" "#000000" "#000000" "#000000" "#000000" "#000000"
[127] "#000000" "#000000" "#000000" "#000000" "#000000" "#000000" "#000000"
[134] "#000000" "#000000" "#000000" "#000000" "#000000" "#000000" "#000000"
[141] "#000000" "#000000" "#000000" "#000000" "#000000" "#000000" "#000000"
[148] "#000000" "#000000" "#000000" "#000000" "#000000" "#000000" "#000000"
[155] "#000000" "#000000" "#000000" "#000000" "#000000" "#000000" "#000000"
[162] "#000000" "#000000" "#000000" "#000000" "#000000" "#000000" "#000000"
[169] "#000000" "#000000" "#000000" "#000000" "#000000" "#000000" "#000000"
[176] "#000000" "#000000" "#000000" "#000000" "#000000" "#000000" "#000000"
[183] "#000000" "#000000" "#000000" "#000000" "#000000" "#000000" "#000000"
[190] "#000000" "#000000" "#000000" "#000000" "#000000" "#000000" "#000000"
[197] "#000000" "#000000" "#000000" "#000000" "#000000" "#000000" "#000000"
[204] "#000000" "#000000" "#000000" "#000000" "#000000" "#000000" "#000000"
[211] "#000000" "#000000" "#000000" "#000000" "#000000" "#000000" "#000000"
[218] "#000000" "#000000" "#000000" "#000000" "#000000" "#000000" "#000000"
[225] "#000000" "#000000" "#000000" "#000000" "#000000" "#000000" "#000000"
[232] "#000000" "#000000" "#000000" "#000000" "#000000" "#000000" "#000000"
[239] "#000000" "#000000" "#000000" "#000000" "#000000" "#000000" "#000000"
[246] "#000000" "#000000" "#000000" "#000000" "#000000" "#000000" "#000000"
[253] "#000000" "#000000" "#000000" "#000000"
Is it me who is doing something wrong in the first place or could it be a bug? And how can I finally access the colortable? I know from calling plot(raster1)
that it should work because the plot displays the correct color-set. Furthermore: Normally, the S4object@someslot
-approach works just fine for me when managing spatial polygon objects.
EDIT:
Beside colortable
the same error appears when trying to access other slots listes by attributes(raster1)
.
Thanks for your help!