Skip to content

Warning when stacking, masking or cropping raster objects

4 messages · Adam Sparks, Thiago V. dos Santos, Loïc Dutrieux

#
Hi all,
I'm working on a vignette from the R-OpenSci auunconf,
https://github.com/saundersk1/auunconf16/blob/master/Vignette%20BoM.Rmd,
and am suddenly getting warning messages where I've never had any before
with this process.

In the "Australian Water Availability Project (AWAP)" section, at the very
end of the file, some grid files are downloaded and saved and GADM level 2
data are fetched to do cropping and masking.

Two weeks ago when we put this together it all worked with no error
messages. Today as I'm working on cleaning up the vignette I'm getting
error messages I've never seen before when doing these things.

For example, the line:
cfiles <- stack(dir(pattern = "grid$"))

Now returns these warning messages:
Warning messages:
1: In `[<-`(`*tmp*`, j, value = <S4 object of class "RasterLayer">) :
  implicit list embedding of S4 objects is deprecated
2: In `[<-`(`*tmp*`, j, value = <S4 object of class "RasterLayer">) :
  implicit list embedding of S4 objects is deprecated
3: In `[<-`(`*tmp*`, j, value = <S4 object of class "RasterLayer">) :
  implicit list embedding of S4 objects is deprecated
4: In `[<-`(`*tmp*`, j, value = <S4 object of class "RasterLayer">) :
  implicit list embedding of S4 objects is deprecated
5: In `[<-`(`*tmp*`, j, value = <S4 object of class "RasterLayer">) :
  implicit list embedding of S4 objects is deprecated
6: In `[<-`(`*tmp*`, j, value = <S4 object of class "RasterLayer">) :
  implicit list embedding of S4 objects is deprecated
7: In `[<-`(`*tmp*`, nl, value = r) :
  implicit list embedding of S4 objects is deprecated

When I try to mask I get similar messages about the implicit list embedding
of S4 objects being deprecated.

For now in the vignette I've suppressed the warning messages as the code
appears to work, it just gives these warnings, but I'd like to understand
why I'm getting them.
6 days later
#
I also noticed those warnings after the last raster update. Here is one simple way to reproduce them:


library(raster)
r <- raster(nrows=100, ncols=100, xmn=5, xmx=10, ymn=46, ymx=51)
r[] <- 1:ncell(r)

# crop raster with a SpatialPolygon* object
if (require(rgdal) & require(rgeos)) {
p <- shapefile(system.file("external/lux.shp", package="raster"))
}

# Crop and mask
rc <- crop(r, extent(p))
rc <- mask(rc, p)


I wonder if there are new instructions to crop/mask rasters that are not yet documented...
Greetings,
 -- Thiago V. dos Santos

PhD student
Land and Atmospheric Science
University of Minnesota
On Tuesday, May 10, 2016 1:45 AM, Adam H Sparks <adamhsparks at gmail.com> wrote:
Hi all,
I'm working on a vignette from the R-OpenSci auunconf,
https://github.com/saundersk1/auunconf16/blob/master/Vignette%20BoM.Rmd,
and am suddenly getting warning messages where I've never had any before
with this process.

In the "Australian Water Availability Project (AWAP)" section, at the very
end of the file, some grid files are downloaded and saved and GADM level 2
data are fetched to do cropping and masking.

Two weeks ago when we put this together it all worked with no error
messages. Today as I'm working on cleaning up the vignette I'm getting
error messages I've never seen before when doing these things.

For example, the line:
cfiles <- stack(dir(pattern = "grid$"))

Now returns these warning messages:
Warning messages:
1: In `[<-`(`*tmp*`, j, value = <S4 object of class "RasterLayer">) :
  implicit list embedding of S4 objects is deprecated
2: In `[<-`(`*tmp*`, j, value = <S4 object of class "RasterLayer">) :
  implicit list embedding of S4 objects is deprecated
3: In `[<-`(`*tmp*`, j, value = <S4 object of class "RasterLayer">) :
  implicit list embedding of S4 objects is deprecated
4: In `[<-`(`*tmp*`, j, value = <S4 object of class "RasterLayer">) :
  implicit list embedding of S4 objects is deprecated
5: In `[<-`(`*tmp*`, j, value = <S4 object of class "RasterLayer">) :
  implicit list embedding of S4 objects is deprecated
6: In `[<-`(`*tmp*`, j, value = <S4 object of class "RasterLayer">) :
  implicit list embedding of S4 objects is deprecated
7: In `[<-`(`*tmp*`, nl, value = r) :
  implicit list embedding of S4 objects is deprecated

When I try to mask I get similar messages about the implicit list embedding
of S4 objects being deprecated.

For now in the vignette I've suppressed the warning messages as the code
appears to work, it just gives these warnings, but I'd like to understand
why I'm getting them.
#
It's related to a change in R, not in raster. See "DEPRECATED AND 
DEFUNCT" related to R 3.3.0 in https://cran.r-project.org/src/base/NEWS

Cheers,
Lo?c
On 05/17/2016 06:20 AM, Thiago V. dos Santos via R-sig-Geo wrote:
#
Thanks, Lo?c, I read the NEWS but didn't fully understand/realise that was
what was happening here.
On 17 May 2016 at 18:03, Lo?c Dutrieux <loic.dutrieux at wur.nl> wrote: