[R-sig-Geo] Warning when stacking, masking or cropping raster objects

Thiago V. dos Santos thi_veloso at yahoo.com.br
Tue May 17 06:20:16 CEST 2016


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.



-- 
Adam Sparks
Associate Professor Field Crops Pathology
Centre for Crop Health
University of Southern Queensland
Toowoomba, QLD, AU

@adamhsparks <https://twitter.com/adamhsparks>

    [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo at r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo



More information about the R-sig-Geo mailing list