[R-sig-Geo] Bug in writeGDAL / create2GDAL?

Roger Bivand Roger.Bivand at nhh.no
Fri Aug 5 12:12:45 CEST 2011


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

> On Fri, Aug 5, 2011 at 11:18 AM, Roger Bivand <Roger.Bivand at nhh.no> wrote:
>
>> 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.
>
>
> Sorry - gdal 1.8.0 from ubuntugis unstable - should I try it with 1.6?
>

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

>
>
>> 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).
>
> OK - the I don't have to try it out.
>
>
>> It is a bit surprising that file() in readAsciiGrid() reads a
>> gzip-compressed file, but it clearly does both for you and me;
>
>
> I just tried it and it worked - it is quite nice.
>
>
>> readGDAL cannot read the compressed file for obvious reasons.
>>
>
> Sure.
>
>
>>
>> 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
>>
>>
>
>
>

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



More information about the R-sig-Geo mailing list