[Raster-commits] r489 - pkg/raster/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Sep 10 08:28:53 CEST 2009


Author: rhijmans
Date: 2009-09-10 08:28:52 +0200 (Thu, 10 Sep 2009)
New Revision: 489

Modified:
   pkg/raster/R/rasterFromNetCDF.R
Log:


Modified: pkg/raster/R/rasterFromNetCDF.R
===================================================================
--- pkg/raster/R/rasterFromNetCDF.R	2009-09-10 06:07:28 UTC (rev 488)
+++ pkg/raster/R/rasterFromNetCDF.R	2009-09-10 06:28:52 UTC (rev 489)
@@ -40,6 +40,12 @@
 	yy <- as.vector(var.get.nc(nc, yvar))
 	yrange <- c(min(yy), max(yy))
 	rm(yy)
+	resx <- (xrange[2] - xrange[1]) / (ncols-1)
+	resy <- (yrange[2] - yrange[1]) / (nrows-1)
+	xrange[1] <- xrange[1] - 0.5 * resx
+	xrange[2] <- xrange[2] + 0.5 * resx
+	yrange[1] <- yrange[1] - 0.5 * resy
+	yrange[2] <- yrange[2] + 0.5 * resy
     r <- raster(xmn=xrange[1], xmx=xrange[2], ymn=yrange[1], ymx=yrange[2], ncols=ncols, nrows=nrows)
     return(r)
 }



More information about the Raster-commits mailing list