On Fri, Aug 5, 2011 at 12:27 PM, Rainer M Krug<r.m.krug at gmail.com> wrote:
On Fri, Aug 5, 2011 at 12:12 PM, Roger Bivand<Roger.Bivand at nhh.no> wrote:
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:
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?
tf1<- tempfile()
tf2<- tempfile()
region<- readAsciiGrid("region.asc.gz")
writeGDAL(region, tf1)
Error in .local(.Object, ...) : Unable to create dataset
writeGDAL(region, "region.txt", drivername="AAIGrid")
Error in .local(.Object, ...) : Unable to create dataset
writeGDAL(region, tf2, drivername="AAIGrid")
Error in .local(.Object, ...) : Unable to create dataset
7: .Call("RGDAL_CreateDataset", driver, as.integer(c(cols, rows,
bands)), as.integer(typeNum), options, my_tempfile, PACKAGE =
"rgdal")
6: .local(.Object, ...)
5: initialize(value, ...)
4: initialize(value, ...)
3: new("GDALTransientDataset", driver = d.drv, rows = dims[2], cols =
dims[1],
bands = nbands, type = type, options = options, fname = fname,
handle = NULL)
2: create2GDAL(dataset = dataset, drivername = copy_drivername,
type = type, mvFlag = mvFlag, fname = NULL, setStatistics =
setStatistics)
1: writeGDAL(region, tf2, drivername = "AAIGrid")
I'll install 1.8.1 from source, reinstall rgdal with that gdal version and
give some feedback - could I ask somebody else on the list to try out my
example, to see if it is only a local issue or caused b=y gdal?
OK -
I compiled gdal 1.8.1,
installed it in $HOME
added $HOME/lib to /etc/ld.so.conf
ran sudo ldconfig
installed rgdal with R CMD INSTALL
--configure-args="--with-gdal-config=/home/rkrug/bin/gdal-config"
rgdal_0.7-1.tar.gz
tried the example again
it worked.
But I still do not know if the problem was locally, or with gdal from
ubuntugis or 1.8.0? No idea - but I am fine with it.
Thanks a lot,
Rainer
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 i 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.
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()
"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
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
--
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology,
UCT), Dipl. Phys. (Germany)
Centre of Excellence for Invasion Biology
Stellenbosch University
South Africa
Tel : +33 - (0)9 53 10 27 44
Cell: +33 - (0)6 85 62 59 98
Fax (F): +33 - (0)9 58 10 27 44
Fax (D): +49 - (0)3 21 21 25 22 44
email: Rainer at krugs.de
Skype: RMkrug