-1

I am trying to upload a bunch of environmental raster layers into R for a SDM. They are all the same extent, pixel size, etc., and most of my layers are uploading fine, but my BIOCLIM layers are not.

I was able to plot each layer and it looked fine, but when I stack them together I get this error:

In .makeRasterList(rlist) : layer(s) with no data ignored

When I look at my stack, only one of my 19 layers is there. I am assuming this error means that some of my pixels have no data, but I don't know how to fix this - any ideas?

edit: I'm not sure if it is a problem in arcmap or R (I believe it may be the former since my other non-climatic layers worked). Here is my code for one of the 19 layers:

ann_mean_temp <- 'ann_mean_temp3.tif'   
ann_mean_temp=brick(ann_mean_temp)   
plot(ann_mean_temp) 

ann_mean_temp  
class       : RasterBrick   
dimensions  : 785, 887, 696295, 1  (nrow, ncol, ncell, nlayers)  
resolution  : 1000, 1000  (x, y)  
extent      : 936315.5, 1823316, -341835.1, 443164.9  (xmin, xmax, ymin, 
ymax)  
coord. ref. : +proj=aea +lat_1=20 +lat_2=60 +lat_0=40 +lon_0=-96 +x_0=0 
+y_0=0 +datum=NAD83 +units=m +no_defs +ellps=GRS80 +towgs84=0,0,0   
data source : C:\Users\Anna\Documents\ArcGIS\R\ann_mean_temp3.tif   
names       : ann_mean_temp3   
min values  :             57   
max values  :            155 

climate <- stack(ann_mean_temp, diurnal_range, Isothermality, 
             temp_seasonality, max_temp_warmest, min_temp_coldest,
             temp_range, temp_wettest, temp_driest,
             mean_temp_warmest, mean_temp_coldest, ann_precip,
             precip_wettest_m, precip_driest_m, precip_seasonality,
             precip_wettest_q, precip_driest_q, precip_warmest,
             precip_coldest)

I'm now getting this error: Error in compareRaster(x) : different number or columns

I should also mention that in arcmap all I did was download each layer from BIOCLIM, project it, extract by mask to clip each layer to my study area, and export it as a tif file.

  • The message suggests that you are making a RasterStack with RasterLayers that have no associated values. Can you provide an example, perhaps with two layers? – Robert Hijmans Nov 22 '17 at 03:39
  • Hi Robert. Thanks for responding. I have 19 BIOCLIM layers that I am trying to import into R to stack together. For example, a couple of the layers are annual precipitation and annual mean temperature. I was able to import each layer individually and plot it, but when I stack them together I get this message. – Raspberria Nov 27 '17 at 19:03
  • Yes, but you appear to be doing something wrong. We cannot point out what it is if you do not show any code. Try to simplify the problem as much as you can. It appears that you are adding an empty (no associated values) RasterLayer. – Robert Hijmans Nov 28 '17 at 01:18
  • Please see edit above – Raspberria Nov 28 '17 at 15:16

1 Answers1

0

all I did was download each layer from BIOCLIM, project it, extract by mask to clip each layer to my study area, and export it as a tif file.

And that should be fine, but you have to make sure that ArcMap does not change the raster origin and resolution, which can be hard to do (check the environment settings).

Alternatively, do all these steps in R.

f <- list.files(pattern="bio")
s <- stack(f)

e <- extent(c(936315.5, 1823316, -341835.1, 443164.9))
r <- raster(nrow=758, ncol=887, ext=e, res=1000, crs="+proj=aea +lat_1=20 +lat_2=60 +lat_0=40 +lon_0=-96 +x_0=0 +y_0=0 +datum=NAD83")

y <- projectRaster(s, r) 

Now go have some coffee. The process should be done when you are back.

Robert Hijmans
  • 40,301
  • 4
  • 55
  • 63