Skip to content

Bug in writeGDAL / create2GDAL?

8 messages · Roger Bivand, Rainer M Krug, Julian Zeidler

#
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:

library(maptools)
library(rgdal)
region <- readAsciiGrid("region.asc.gz")
image(region)
writeGDAL(region, "region.tif")
## RESULT: Error in .local(.Object, ...) : Unable to create dataset
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"
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
#
On Fri, 5 Aug 2011, Rainer M Krug wrote:

            
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
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)
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

  
    
#
On Fri, 5 Aug 2011, Rainer M Krug wrote:

            
Do they have 1.8.1? It shouldn't make any difference, but there have been 
many reports about instability in ubuntu binary GDAL over many versions. I 
only ever build GDAL from source, so I have control over the drivers. The 
binary build train may have assumed particular versions of external shared 
objects, for example.

Could you try:

tf1 <- tempfile()
tf2 <- tempfile()
writeGDAL(region, tf1)
writeGDAL(region, "region.txt", drivername="AAIGrid")
writeGDAL(region, tf2, drivername="AAIGrid")

to write to a different directory and use a different driver?

Roger

  
    
#
Hi Rainer,

I am also running gdal from ubuntugis unstable with rgdal_0.7-1. (on an 
x64 Ubuntu 11.04), so was curious if I was affected as well.

However the test as suggested by Robert works for me without a hitch.

Best,
Julian





Am 05.08.2011 14:01, schrieb Rainer M Krug: