rspatial / geodata

download geographic data
GNU General Public License v3.0
147 stars 15 forks source link

Bioclim variables mis-identified in worldclim_tile() output #38

Open jbyoder opened 1 year ago

jbyoder commented 1 year ago

I'm using worldclim_tile() to obtain Bioclim layers at 0.5-min resolution for the first time, and I've run into what seems to be incorrect labeling of the layers. Running

BClim <- worldclim_tile(var="bio", res=0.5, lat=33.75, lon=-118, path="data/")

Returns a RasterStack with layers labeled in order from 1 to 19. However, the values in those layers don't align with anything like what they should be, given the identity of the variables. I first noticed it in comparing bio12 (annual precipitation) and bio13 (precip in the wettest month) — the former should, arithmetically, always be larger than the latter. However, the range of values for the bio12 layer in the stack downloaded above is about 5 to 25, and the range for the bio13 layer is about 26 to 66. (Squinting at hist() outputs to get those.) Subtracting the bio13 layer values from bio12 layer values gets me between about -54 and -8.

Looking across the 19 layers with plot() shows ranges of values that look like they should correspond to Bioclim variables, but not the ones labeled.

plot(BClim)

Screen Shot 2023-01-11 at 15 36 31

As one final check, I went back to getData() from raster, which pulls down WoldClim 1.4 instead of 2.1, and obtained values that make much more sense for the labeled variables.

BClim2 <- getData(name="worldclim", var="bio", res=0.5, lat=33.75, lon=-118, path="data/")
plot(BClim2)

Screen Shot 2023-01-11 at 15 40 06

cjcarlson commented 1 year ago

Just a note that I've independently reproduced this issue and agree that the output of worldclim_tile doesn't look right. Watching to see what the answer is! Thanks so much Robert!

Maerien42 commented 1 year ago

Hey everybody, I am quite late with my comment and I am not sur if this was already solved. I observed the same issue when dowloading the data in R. I correlated the data from version 1.4 to 2.1 and it seems that the order of bioclim variables is like the following: 1, 10, 11,12, 13, 14, 15, 16, 17, 18, 19, 2, 3 etc. I guess this comes from the fact that when creating the multband raster the layers where ordered reading the numbers as characters and not as numbers. version2 1vs1 4 (version 2.1 = rows, version 1.4 = columns

rjaffe-ramboll commented 9 months ago

I just opened a new issue about the same problem: https://github.com/rspatial/geodata/issues/56