I am attempting to plot specific layers from a set of time-series rasters contained in RData format. I used the code below:


loadset <- load("MOD13Q1_MYD13Q1_EVI_97_2008_89_2009_RData.RData")
getset <- get(loadset) #successfully extracted the contents of RData file
set <- raster::stack(getset)

However when I start to plot or check the histogram using this code:

r1 <- raster(set, layer=1)

I get an error:

Error in .local(.Object, ...) :

What does this error mean and what's the workaround?

RData files can be found HERE.

  • You need to require the associated libraries. They ate not added back when the session is opened. – Jeffrey Evans Jul 31 '19 at 23:08
  • Hi @JeffreyEvans, I have these libraries:library(maptools) library(maps) library(rgdal) library(sp) library(spdplyr) library(raster) library(rgeos) – mand3rd Jul 31 '19 at 23:12

Look at the object


or check if it has an associated filename:


The source points to a filepath on someone's computer, and what happened was they created a raster object linked to a file i.e.

s <- stack("MOD13Q1_EVI_2008_097.tif")

and then saved it out

save(s, "myfile.RData")

All that did was save a summary of the object, like the print above - but none of the actual data from the .tif file.

This is an unfortunate side-effect of the very nice behaviour raster has of not loading any data until it is really needed.

They needed to do this before saving to .RData

s <- readAll(s)

But, .RData is a bad file format for this, better to use writeRaster(s, filename = "somefile") and choose a given format (like GeoTIFF, or even raster's own .gri/.grd).

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.