Converting ncdf to geoTIFF

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Converting ncdf to geoTIFF

John Wasige
Dear all,
This is to request for help on how to convert ncdf data to geoTIFF in R
with my script below;

my script is:
library(raster)
library(ncdf)

setwd('D:/Lund2015/CRU1982_2011')

prec1 <- open.ncdf('D:/Lund2015/CRU1982_2011/
b8_cruts3.20_pre_19820101_20111231_1month_mean.nc')
print(prec1)
rast<-raster(prec1, varname="pre")

I am getting the following error:

[1] "file D:/Lund2015/CRU1982_2011/b8_cruts3.20_pre_19820101_20111231_1month_mean.nc
has 3 dimensions:"
[1] "lon   Size: 167"
[1] "lat   Size: 146"
[1] "time   Size: 360"
[1] "------------------------"
[1] "file D:/Lund2015/CRU1982_2011/b8_cruts3.20_pre_19820101_20111231_1month_mean.nc
has 1 variables:"
[1] "double pre[lon,lat,time]  Longname:precipitation
Missval:9.96920996838687e+36"> rast<-raster(prec1, varname="pre")Error
in (function (classes, fdef, mtable)  :
  unable to find an inherited method for function ‘raster’ for
signature ‘"ncdf"’


>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Converting ncdf to geoTIFF

Michael Sumner-2
raster() wants the filename, not a NetCDF connection.

(raster is one of *very* few high-level interfaces to NetCDF, so it's
somewhat unfamiliar to the norm)

Cheers, Mike

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.