dimanche 1 février 2015

How to read *.adf files into R?


I want to load .adf files into R. The data is from this page: http://ift.tt/1zcqJMt


I tried the following code that I found after some research in the internet. The problem is, that in the class RasterLayer I get negativ values that shouldn't be there. I don't know why this happens, so hopefully someone can help me!?


Code:



library(rgdal)
library(RColorBrewer)
dpath<- path...

x <- new("GDALReadOnlyDataset", dpath)
getDriver(x)
getDriverLongName(getDriver(x))
xx<-asSGDF_GROD(x)
r <- raster(xx)


The output for 'r' is:



r class : RasterLayer dimensions : 2160, 4320, 9331200 (nrow, ncol, ncell) resolution : 0.08333333, 0.08333333 (x, y) extent : -180, 180, -90, 90 (xmin, xmax, ymin, ymax) coord. ref. : +proj=longlat +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +no_defs data source : in memory names : band1 values : -997, 16 (min, max)



The '16' in the values refers to the 16 classes of length of growing period. But I wonder where those '-997' come from. Maybe something wrong with the coord. ref?


Here is also a data summary of 'xx':


Data summary: Min. 1st Qu. Median Mean 3rd Qu. Max. NA's -997 3 5 -9 8 16 7123158


And if we look at the data in xx more closely:



table(xx$band1)



-997 1 2 3 4 5 6 7 8 9 10 11 12 31711 429643 83011 166674 207228 270161 240958 183342 118608 98795 88473 73743 56022 13 14 15 16 30104 45521 52216 31832


There is really just this '-997' thing in it. I think the NAs are ozeans, so is there something wrong with the data loading or do I just don't understand the data?





Aucun commentaire:

Enregistrer un commentaire