Skip to content

projectRaster error with netcdf

2 messages · Tom Hilinski, Robert J. Hijmans

#
Having an error in getting library raster to read data from a netcdf
file when reprojecting a raster.
I'd appreciate any workarounds you can suggest.
Here's the debug transcript:

-----
debug at NARR.R#142: r <- projectRaster(r, "+proj=longlat +ellps=WGS84
+datum=WGS84 +no_defs")

Browse[2]> r
class       : RasterLayer
band        : 1
dimensions  : 277, 349, 96673  (nrow, ncol, ncell)
resolution  : 0.8428132, 0.1651133  (x, y)
extent      : -145.5, 148.6418, 0.897945, 46.63433  (xmin, xmax, ymin, ymax)
projection  : +proj=lcc +lat_1=50.0 +lat_2=50.0 +lon_0=-107.0
+lat_0=50.0 +x_0=5632642.22547 +y_0=4612545.65137 +ellps=WGS84
+datum=WGS84 +units=m +no_defs +towgs84=0,0,0
values      : <snip>/soilm.mon.mean.nc
min         : ?
max         : ?

Browse[2]> file.exists( r at file@name )
[1] TRUE

Browse[2]> n
Error in .rasterObjectFromFile(x, band = band, objecttype =
"RasterLayer",  :
  Cannot create a RasterLayer object from this file. (file does not exist)
-----

library versions:
raster_1.8-12 rgdal_0.6-33  sp_0.9-81     ncdf_1.6.5
#
The second argument in projectRaster is another Raster* object, not a proj.4
string. 

I expect this problem goes away if you do:

x <- projectRaster(r, crs="+proj=longlat +ellps=WGS84 +datum=WGS84
+no_defs")

Robert
--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/projectRaster-error-with-netcdf-tp6359514p6359973.html
Sent from the R-sig-geo mailing list archive at Nabble.com.