[Raster-commits] r282 - in pkg/raster: . R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Feb 13 06:04:51 CET 2009


Author: rhijmans
Date: 2009-02-13 06:04:51 +0100 (Fri, 13 Feb 2009)
New Revision: 282

Modified:
   pkg/raster/NAMESPACE
   pkg/raster/R/read.raster.R
Log:


Modified: pkg/raster/NAMESPACE
===================================================================
--- pkg/raster/NAMESPACE	2009-02-12 15:11:46 UTC (rev 281)
+++ pkg/raster/NAMESPACE	2009-02-13 05:04:51 UTC (rev 282)
@@ -4,5 +4,5 @@
 importFrom("utils", stack)
 importFrom("sp", overlay, bbox, Spatial, SpatialPixels, SpatialPixelsDataFrame, SpatialGrid, SpatialGridDataFrame)
 exportClasses(BoundingBox, BasicRaster, Raster, RasterLayer, RasterStack)
-exportMethods(overlay, bbox, aggregate, stack, median, show, summary, plot, hist, ncol, nrow, dim)
+exportMethods(calc, overlay, bbox, aggregate, stack, median, show, summary, plot, hist, ncol, nrow, dim)
 exportPattern("^[^\\.]")
\ No newline at end of file

Modified: pkg/raster/R/read.raster.R
===================================================================
--- pkg/raster/R/read.raster.R	2009-02-12 15:11:46 UTC (rev 281)
+++ pkg/raster/R/read.raster.R	2009-02-13 05:04:51 UTC (rev 282)
@@ -80,7 +80,7 @@
 			result <- readBin(con, what=dtype, n=ncell(raster), size=raster at file@datasize, signed=raster at file@datasigned, endian=raster at file@byteorder) 
 		}
 		close(con)
-		result[is.nan(result)] <- NA
+#		result[is.nan(result)] <- NA
 		if (dtype == 'numeric') {
 			result[result <=  (0.999 * .nodatavalue(raster)) ] <- NA 	
 		} else {
@@ -103,7 +103,16 @@
 			}
 		}
 		result <- getRasterData(raster at file@gdalhandle[[1]], offset=offs, region.dim=reg, band = raster at file@band)
-		if (!is.vector(result)) { result <- as.vector(result) }
+		
+#		if (!is.vector(result)) {  result <- as.vector(result) 	}
+		
+		# if  setNAvalue() has been used.....
+		if (raster at file@nodatavalue < 0) {
+			result[result <= raster at file@nodatavalue ] <- NA 			
+		} else {
+			result[result == raster at file@nodatavalue ] <- NA 					
+		}
+	
 	} 
 	
 	raster at data@values <- as.vector(result)



More information about the Raster-commits mailing list