[Raster-commits] r433 - pkg/raster/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Apr 27 05:58:25 CEST 2009
Author: rhijmans
Date: 2009-04-27 05:58:22 +0200 (Mon, 27 Apr 2009)
New Revision: 433
Modified:
pkg/raster/R/properties.R
pkg/raster/R/removeRasterFile.R
Log:
Modified: pkg/raster/R/properties.R
===================================================================
--- pkg/raster/R/properties.R 2009-04-26 13:45:59 UTC (rev 432)
+++ pkg/raster/R/properties.R 2009-04-27 03:58:22 UTC (rev 433)
@@ -4,9 +4,6 @@
# Version 0.8
# Licence GPL v3
-
-
-
band <- function(object) {
if (class(object) == "RasterLayer") {
return(object at file@band)
@@ -43,13 +40,17 @@
.driver <- function(object) {
- if (class(object at file@con)[1] == 'file') {
+ fcon <- class(try( object at file@con, silent = T ))[1]
+ if (fcon == 'file') {
return('raster')
- } else if (class(object at file@con)[1] == "GDALReadOnlyDataset") {
+ } else if (fcon == "GDALReadOnlyDataset") {
return('gdal')
+ } else if (fcon == "try-error") {
+ return('NA')
} else {
- stop('could not determine driver')
+ stop('unknown driver')
}
+
}
.nodatavalue <- function(object) {
Modified: pkg/raster/R/removeRasterFile.R
===================================================================
--- pkg/raster/R/removeRasterFile.R 2009-04-26 13:45:59 UTC (rev 432)
+++ pkg/raster/R/removeRasterFile.R 2009-04-27 03:58:22 UTC (rev 433)
@@ -8,7 +8,7 @@
removeRasterFile <- function(raster) {
if (class(raster) == 'RasterLayer') {
fname <- filename(raster)
-# to do: need to close the connection in the object in the Global environement
+# need to close the connection in the object in the Global environement; not here ????
raster <- closeConnection(raster)
filename(raster) <- ''
} else {
More information about the Raster-commits
mailing list