Projecting NetCDF Files as Raster Bricks

I need to change the projections of the NetCDF files, so I have read one into R and have been trying to manipulate it there.

f <- file.path("C:/nco/out.nc")
tmin <- brick(f,varname="tmin")
Albers <- "+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-96 +x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m +no_defs"
proj1 <- projectRaster(tmin,crs=Albers)

Invariably, this leads to a blank raster, where all the values have been replaced with NA. So, something is wrong: I’m trying to maybe put something into the wrong space where it’s not fitting/lining up? A few things that also make me wonder what’s wrong…

  • it can’t rotate (raster::rotate gives me an error saying it doesn’t “look like an appropriate object for this function”)
  • a function like raster(inputfile, varname="lat")doesn’t work; when I try that, it says that “lat” is not a variable (though it’s a dimension for the actual variable of interest, “tmin” in this case, which seems to work for other intents and purposes).

Ideas…

  • use gdalwarp instead to project the NetCDF?
  • after projecting, make the shape file line up to 0-360 coordinates?

Leave a Reply

Your email address will not be published. Required fields are marked *