[R-sig-Geo] netcdf to raster

Sam Veloz sdveloz at ucdavis.edu
Fri Sep 4 23:33:04 CEST 2009


Great that works.
Thanks,
Sam

Robert J. Hijmans wrote:
> Hi Sam, 
>
> This should work 
>
> m <- t(test.1.1999)
> m <- m[nrow(m):1,]
> r <- raster(m)
> plot(r)
>
> Robert
>
> On Fri, Sep 4, 2009 at 11:25 AM, Sam Veloz <sdveloz at ucdavis.edu 
> <mailto:sdveloz at ucdavis.edu>> wrote:
>
>     I am working with some climate data in Netcdf format that are
>     available here:
>     http://hydro.engr.scu.edu/files/gridded_obs/monthly/ncfiles/
>
>     I can successfully read in the files and plot individual bands:
>     library(ncdf)
>     test.nc
>     <http://test.nc><-open.ncdf("gridded_obs.monthly.Tmin.1999.nc
>     <http://gridded_obs.monthly.Tmin.1999.nc>")
>     test.1.1999<-get.var.ncdf(test.nc
>     <http://test.nc>,varid="Tmin",start=c(1,1,1),count=c(462,222,1))
>     library(raster)
>     image(test.1.1999) #looks good
>     test.raster<-raster(test.1.1999)
>     image(test.raster) #now North America is on its side, east coast
>     of NA is now on the south side of the image
>
>     Is it possible to convert this file to a raster file without
>     having the axes switched? Any guesses what I am doing wrong?
>
>     I had a similar problem using gdal_translate where the output was
>     a mirror image of what it should have been.
>     Thanks,
>     Sam
>
>     -- 
>     ****************************************************
>     Sam Veloz
>     Postdoctoral Researcher
>     Department of Environmental Science and Policy
>     University of California, Davis
>     sdveloz at ucdavis.edu <mailto:sdveloz at ucdavis.edu>
>
>     _______________________________________________
>     R-sig-Geo mailing list
>     R-sig-Geo at stat.math.ethz.ch <mailto:R-sig-Geo at stat.math.ethz.ch>
>     https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
>


-- 
****************************************************
Sam Veloz
Postdoctoral Researcher
Department of Environmental Science and Policy
University of California, Davis
sdveloz at ucdavis.edu



More information about the R-sig-Geo mailing list