Bug in writeGDAL / create2GDAL?
On Fri, 5 Aug 2011, Rainer M Krug wrote:
Hi
I get an error in writeGDAL(), narrowed down in the call to
tds.out = new("GDALTransientDataset", driver = d.drv, rows = dims[2],
cols = dims[1], bands = nbands, type = type, options = options,
fname = fname, handle = NULL)
in create2GDAL.
This error is for me reproducible:
with the attached file, execute:
Thanks for the example. For me all works as expected, system details below. You don't say which GDAL version you are running. I'm running rgdal from R-forge, but the changes do not affect the GDAL interface (added function for drawing a longlat grid over projected data). It is a bit surprising that file() in readAsciiGrid() reads a gzip-compressed file, but it clearly does both for you and me; readGDAL cannot read the compressed file for obvious reasons. Roger
library(rgdal)
Geospatial Data Abstraction Library extensions to R successfully loaded Loaded GDAL runtime: GDAL 1.8.1, released 2011/06/04 Path to GDAL shared files: /usr/local/share/gdal Loaded PROJ.4 runtime: Rel. 4.7.1, 23 September 2009, [PJ_VERSION: 470] Path to PROJ.4 shared files: (autodetected)
sessionInfo()
R version 2.13.1 (2011-07-08) Platform: i686-pc-linux-gnu (32-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=C LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] rgdal_0.7-2 maptools_0.8-9 lattice_0.19-31 sp_0.9-84 [5] foreign_0.8-45 loaded via a namespace (and not attached): [1] grid_2.13.1
library(maptools)
library(rgdal)
region <- readAsciiGrid("region.asc.gz")
image(region)
writeGDAL(region, "region.tif")
## RESULT: Error in .local(.Object, ...) : Unable to create dataset
Sys.info()
sysname
"Linux"
release
"2.6.38-10-generic"
version
"#46-Ubuntu SMP Tue Jun 28 15:05:41 UTC 2011"
nodename
"ecolmod"
machine
"i686"
login
"rkrug"
user
"rkrug"
sessionInfo()
R version 2.13.1 (2011-07-08) Platform: i686-pc-linux-gnu (32-bit) locale: [1] LC_CTYPE=en_GB.utf8 LC_NUMERIC=C [3] LC_TIME=en_GB.utf8 LC_COLLATE=en_GB.utf8 [5] LC_MONETARY=C LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_GB.utf8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_GB.utf8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] rgdal_0.7-1 maptools_0.8-9 lattice_0.19-30 sp_0.9-84 [5] foreign_0.8-44 loaded via a namespace (and not attached): [1] grid_2.13.1 tools_2.13.1
Cheers, Rainer
Roger Bivand Department of Economics, NHH Norwegian School of Economics, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: Roger.Bivand at nhh.no