[R-sig-Geo] gdal error 1 (execution halted)

Lienert Christophe lienert at karto.baug.ethz.ch
Fri Mar 14 11:44:34 CET 2008


Dear All,
Parts of the he following email have been already posted on the R-devel list, but is supplemented with the code that may cause the error discussed below and put on the R-sig-geo list at the suggestion of Mr. Bivand.
 
I am using R 2.6.2 on my Redhat AS4. I installed the RPM offered on the cran website. I would like to use R from my bash console with the following command:

/path/to/R --vanilla --slave --args < /data/myscript.R

this script invokes a range of functions and tools, among others to process a bunch of raster images in a loop using GDAL. The thing is that releasing this command in the bash results in the following error:
 
ERROR:
*************************************

Error in GDAL.close(tds.out) :
        GDAL Error 1: TIFFReadDirectory:/tmp/RtmpBgrSyt/file2ef6a5b2: cannot handle zero scanline size
Calls: plot.georef -> GDAL.close -> .Call
Execution halted



CODE:
*************************************


plot.georef=function(grid.sp,graph.file,col.palette,breaks){

  require("sp")
  require("rgdal")

  # get desired picture type
  base.name=strsplit(graph.file,"/")[[1]][length(strsplit(graph.file,"/")[[1]])]
  ft=0
  ft=sum(c(ft,grep(".tiff",base.name)))
  if (ft==1){ file.typ="TIFF" }
  ft=0
  ft=sum(c(ft,grep(".jpg",base.name)))
  if (ft==1){ file.typ="JPG" }
  ft=0
  ft=sum(c(ft,grep(".png",base.name)))
  if (ft==1){ file.typ="PNG" }

  # create RGB bands
  names(grid.sp)=c("band1","band2")
  grid.sp$band3=grid.sp$band2
  grid.sp$band4=grid.sp$band2
  
  col.class=as.vector(cut(grid.sp$band1,br = breaks, labels=col.palette))
  col.class[is.na(col.class)]="#FFFFFF"
  col.class.rgb=col2rgb(col.class)

  grid.sp$band1=col.class.rgb["red",]
  grid.sp$band2=col.class.rgb["green",]
  grid.sp$band3=col.class.rgb["blue",]
  grid.sp$band4[]=256

  if (file.typ=="TIFF"){

    #writeGDAL(grid.sp, graph.file,drivername = "GTiff",type = "band",options="ALPHA=YES")
    tds.out <- create2GDAL(dataset=grid.sp,drivername="GTiff",type="band")
    saveDataset(tds.out,graph.file)
    GDAL.close(tds.out)
  }
}




The error is most likely in the if control. Both variants (the with only the commented line and the one with only the three following lines) produce the error.  
Thanks for any help!

Ciao,

Chris

_______________________________________________
Christophe Lienert 
ETH Zurich 
Institute of Cartography 
Wolfgang-Pauli-Str. 15 
HIL G 13.3 
CH-8093 Zurich
SWITZERLAND

Fon: +41-44-6333036 
Fax: +41-44-6331153
www.karto.ethz.ch 
lienert at karto.baug.ethz.ch




More information about the R-sig-Geo mailing list