[R-sig-Geo] Problem reading files through rgdal

Agustin Lobo alobolistas at gmail.com
Tue Dec 13 10:29:42 CET 2011


Just adding more details: gdalinfo works fine on the same file for
which infoGDAL() fails:

Also, after reinstalling rgdal from cran, I get a warning:
> GDALinfo(paste(datawd,"/SPOTmultispectral/SP2003ATC_atm2.tif",sep=""))
Error in .local(.Object, ...) :
  WARNING ! libtiff version mismatch : You're linking against libtiff
3.X but GDAL has been compiled against libtiff >= 4.0.0
> system("gdalinfo /media/Iomega_HDD/MASTER_ICTA2007_2008/ExercisesJEMES/ExerciseFIRESPOT/Data_ExerciseFIRESPOT/SPOTmultispectral/SP2003ATC_atm2.tif",intern=T)
 [1] "Driver: GTiff/GeoTIFF"
 [2] "Files: /media/Iomega_HDD/MASTER_ICTA2007_2008/ExercisesJEMES/ExerciseFIRESPOT/Data_ExerciseFIRESPOT/SPOTmultispectral/SP2003ATC_atm2.tif"
 [3] "       /media/Iomega_HDD/MASTER_ICTA2007_2008/ExercisesJEMES/ExerciseFIRESPOT/Data_ExerciseFIRESPOT/SPOTmultispectral/SP2003ATC_atm2.tfw"
 [4] "       /media/Iomega_HDD/MASTER_ICTA2007_2008/ExercisesJEMES/ExerciseFIRESPOT/Data_ExerciseFIRESPOT/SPOTmultispectral/SP2003ATC_atm2.tif.aux.xml"
 [5] "Size is 2221, 1950"
 [6] "Coordinate System is:"
 [7] "PROJCS[\"ED50 / UTM zone 31N\","
 [8] "    GEOGCS[\"ED50\","
 [9] "        DATUM[\"European_Datum_1950\","
[10] "            SPHEROID[\"International
1924\",6378388,297.0000000000014,"
[11] "                AUTHORITY[\"EPSG\",\"7022\"]],"
[12] "            AUTHORITY[\"EPSG\",\"6230\"]],"
[13] "        PRIMEM[\"Greenwich\",0],"
[14] "        UNIT[\"degree\",0.0174532925199433],"
[15] "        AUTHORITY[\"EPSG\",\"4230\"]],"
[16] "    PROJECTION[\"Transverse_Mercator\"],"
[17] "    PARAMETER[\"latitude_of_origin\",0],"
[18] "    PARAMETER[\"central_meridian\",3],"
[19] "    PARAMETER[\"scale_factor\",0.9996],"
[20] "    PARAMETER[\"false_easting\",500000],"
[21] "    PARAMETER[\"false_northing\",0],"
[22] "    UNIT[\"metre\",1,"
[23] "        AUTHORITY[\"EPSG\",\"9001\"]],"
[24] "    AUTHORITY[\"EPSG\",\"23031\"]]"
[25] "Origin = (404629.090000000025611,4624285.299999999813735)"
[26] "Pixel Size = (10.000000000000000,-10.000000000000000)"
[27] "Metadata:"
[28] "  TIFFTAG_XRESOLUTION=300"
[29] "  TIFFTAG_YRESOLUTION=300"
[30] "  TIFFTAG_RESOLUTIONUNIT=2 (pixels/inch)"
[31] "  AREA_OR_POINT=Area"
[32] "Image Structure Metadata:"
[33] "  INTERLEAVE=PIXEL"
[34] "Corner Coordinates:"
[35] "Upper Left  (  404629.090, 4624285.300) (  1d51' 9.77\"E,
41d45'50.20\"N)"
[36] "Lower Left  (  404629.090, 4604785.300) (  1d51'20.98\"E,
41d35'18.04\"N)"
[37] "Upper Right (  426839.090, 4624285.300) (  2d 7'11.49\"E,
41d45'58.68\"N)"
[38] "Lower Right (  426839.090, 4604785.300) (  2d 7'20.10\"E,
41d35'26.47\"N)"
[39] "Center      (  415734.090, 4614535.300) (  1d59'15.58\"E,
41d40'38.63\"N)"
[40] "Band 1 Block=2221x16 Type=Byte, ColorInterp=Gray"
[41] "Band 2 Block=2221x16 Type=Byte, ColorInterp=Undefined"
[42] "Band 3 Block=2221x16 Type=Byte, ColorInterp=Undefined"
[43] "Band 4 Block=2221x16 Type=Byte, ColorInterp=Undefined"



Agus


2011/12/13 Agustin Lobo <alobolistas at gmail.com>:
> Hi!
>
> I have this problem and think it's related to rgdal (or rather to gdal).
>
> r <- raster(ncol=10, nrow=10)
> r1 <- init(r, fun=runif)
> r2 <- init(r, fun=runif)
> r3 <- overlay(r1, r2, fun=function(x,y){return(x+y)})
>> writeRaster(r3,filename="delme.tif",format="GTiff",overwrite=T,datatype="FLT4S")
> Error in .local(.Object, ...) : Unable to create dataset
>> sp2003 <- brick(paste(datawd,"/SPOTmultispectral/SP2003ATC_atm2.tif",sep=""))
> Error in .rasterObjectFromFile(x, objecttype = "RasterBrick", ...) :
>  Cannot create a RasterLayer object from this file.
>> delme = readGDAL(paste(datawd,"/SPOTmultispectral/SP2003ATC_atm2.tif",sep=""))
> Error in .local(.Object, ...) :
>
> `/media/Iomega_HDD/MASTER_ICTA2007_2008/ExercisesJEMES/ExerciseFIRESPOT/Data_ExerciseFIRESPOT/SPOTmultispectral/SP2003ATC_atm2.tif'
> not recognised as a supported file format.
>
>> GDALinfo(paste(datawd,"/SPOTmultispectral/SP2003ATC_atm2.tif",sep=""))
> Error in .local(.Object, ...) :
>
> `/media/Iomega_HDD/MASTER_ICTA2007_2008/ExercisesJEMES/ExerciseFIRESPOT/Data_ExerciseFIRESPOT/SPOTmultispectral/SP2003ATC_atm2.tif'
> not recognised as a supported file format.
>
> I can read/write any external file not using rgdal, and save() and
> save.image() work fine:
>> save.image()
>> x = data.frame(var1=1:10,var2=LETTERS[1:10])
>> x
>   var1 var2
> 1     1    A
> 2     2    B
> 3     3    C
> 4     4    D
> 5     5    E
> 6     6    F
> 7     7    G
> 8     8    H
> 9     9    I
> 10   10    J
>> write.csv(x,file="x.csv")
>> x2 <- read.csv("x.csv")
>> x2
>    X var1 var2
> 1   1    1    A
> 2   2    2    B
> 3   3    3    C
> 4   4    4    D
> 5   5    5    E
> 6   6    6    F
> 7   7    7    G
> 8   8    8    H
> 9   9    9    I
> 10 10   10    J
>
> It seems to me a problem with gdal, my version is 1.8.0.2 from
> ubuntugis-unstable binaries for ubuntu 10.04
> Are you aware of any problem with gdal and/or rgdal?
>
> Thanks,
>
> Agus
>
>> sessionInfo()
> R version 2.14.0 (2011-10-31)
> Platform: x86_64-pc-linux-gnu (64-bit)
>
> locale:
>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C LC_TIME=en_US.UTF-8
>  LC_COLLATE=en_US.UTF-8
>  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8    LC_PAPER=C
>              LC_NAME=C
>  [9] LC_ADDRESS=C               LC_TELEPHONE=C
> 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-5   raster_1.9-55 sp_0.9-89
>
> loaded via a namespace (and not attached):
> [1] grid_2.14.0     lattice_0.19-30 tools_2.14.0



More information about the R-sig-Geo mailing list