read_stars in stars package give me NA values -- what should I do?

18 Views Asked by At

I am trying to open a tiff file with read_stars but all values turned out NA. I opened the same file with raster package and there are values. I am new to stars package and hope to learn it as raster package is retiring.

I downloaded a tiff file from here. I downloaded prec_2010-2019 zip file and there are several tiff files. The exact file I used is wc2.1_cruts4.06_2.5m_prec_2010-2019/wc2.1_2.5m_prec_2010-01.tif.

I open the file with read_stars. As you see below, all values are NA.

> data201001 <- read_stars("./wc2.1_cruts4.06_2.5m_prec_2010-2019/wc2.1_2.5m_prec_2010-01.tif")
> data201001
stars object with 2 dimensions and 1 attribute
attribute(s), summary of first 1e+05 cells:
                             Min. 1st Qu. Median Mean 3rd Qu. Max.  NA's
wc2.1_2.5m_prec_2010-01.tif    NA      NA     NA  NaN      NA   NA 1e+05
dimension(s):
  from   to offset    delta refsys point x/y
x    1 8640   -180  0.04167 WGS 84 FALSE [x]
y    1 4320     90 -0.04167 WGS 84 FALSE [y]

I open the same file with raster. It shows the min and max values.

> data201001_raster <- raster("./wc2.1_cruts4.06_2.5m_prec_2010-2019/wc2.1_2.5m_prec_2010-01.tif")
> data201001_raster
class      : RasterLayer 
dimensions : 4320, 8640, 37324800  (nrow, ncol, ncell)
resolution : 0.04166667, 0.04166667  (x, y)
extent     : -180, 180, -90, 90  (xmin, xmax, ymin, ymax)
crs        : +proj=longlat +datum=WGS84 +no_defs 
source     : wc2.1_2.5m_prec_2010-01.tif 
names      : wc2.1_2.5m_prec_01 
values     : 0, 1370.7  (min, max)

I guess I might need to specify something in read_stars but I am not sure what to do. Thank you for your help!

0

There are 0 best solutions below