1

I was converting the .nc file downloaded from here to raster to map the SST spatial variation. The unit is supposed to be in Kelvin. But the values I got are not in normal ranges (degree celsius or Kelvin). Here's my code:

library(ncdf4)
nasa.temp <- nc_open("20171012090000-JPL-L4_GHRSST-SSTfnd-MUR-GLOB-v02.0-fv04.1.nc")

lon <- ncvar_get(nasa.temp, "lon")
lat <- ncvar_get(nasa.temp, "lat", verbose = F)
t <- ncvar_get(nasa.temp, "time")

ndvi.array <- ncvar_get(nasa.temp, "analysed_sst") 
fillvalue <- ncatt_get(nasa.temp, "analysed_sst", "_FillValue")

ncatt_get(nasa.temp, "analysed_sst","units")

ndvi.array[ndvi.array == fillvalue$value] <- NA

r <- raster(t(ndvi.array), xmn=min(lon), xmx=max(lon), ymn=min(lat), ymx=max(lat), 
            crs=CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs+ towgs84=0,0,0"))
r <- flip(r, direction='y')

MY.ext <- extent(99.64072, 120.2697, 0.05372, 8.380556)
sst.crop <- crop(r, MY.ext)
plot(sst.crop)

writeRaster(sst.crop, "nasa/sst.tif", "GTiff", overwrite=TRUE)

enter image description here

Really appreciate it if anyone can help to point out my mistakes!

  • 1
    For the reference for those from different backgrounds, could you include expected or "normal ranges" for SST in Kelvin for that date & area? Values around ~30C does not sound too much off, but perhaps it's the 5K range (306-301) that does not make much sense? – margusl Jul 22 '23 at 08:04
  • I just realized that I didn't convert K to C! It makes sense now. Thanks for reminding! – LauraEverdeen Jul 22 '23 at 16:10

0 Answers0