[R-sig-Geo] raster package: overlay changes geometry

Agustin Lobo alobolistas at gmail.com
Tue Oct 27 11:44:24 CET 2009


Hi!

I've done:
r1 <- raster("SDIM0160.tif",band=1)
r2 <- raster("SDIM0160.tif",band=2)
r3 <- raster("SDIM0160.tif",band=3)
f <- function(x,y,z,coefs=calcoefs) coefs[1,1]*x+coefs[1,2]*y+coefs[1,3]*z
overlay(r1,r2,r3,fun=f,filename="SDIM0160_miL1.tif"filetype='GTiff')

The problem is that the resulting raster does not have the same geometry 
as the input one.

Input:
$ gdalinfo SDIM0160.tif
Warning 1: TIFFReadDirectory:Unknown field with tag 37717 (0x9355) 
encountered
Driver: GTiff/GeoTIFF
Files: SDIM0160.tif
Size is 2640, 1760
Coordinate System is `'
Metadata:
   TIFFTAG_SOFTWARE=SIGMA PhotoPro 2.4.0.3198
   TIFFTAG_DATETIME=2009:09:22 15:56:48
   TIFFTAG_XRESOLUTION=180
   TIFFTAG_YRESOLUTION=180
   TIFFTAG_RESOLUTIONUNIT=2 (pixels/inch)
Image Structure Metadata:
   INTERLEAVE=PIXEL
Corner Coordinates:
Upper Left  (    0.0,    0.0)
Lower Left  (    0.0, 1760.0)
Upper Right ( 2640.0,    0.0)
Lower Right ( 2640.0, 1760.0)
Center      ( 1320.0,  880.0)
Band 1 Block=2640x1 Type=Byte, ColorInterp=Red
Band 2 Block=2640x1 Type=Byte, ColorInterp=Green
Band 3 Block=2640x1 Type=Byte, ColorInterp=Blue

Output:
$ gdalinfo SDIM0160_miL1.tif
Driver: GTiff/GeoTIFF
Files: SDIM0160_miL1.tif
Size is 2640, 1760
Coordinate System is `'
Origin = (0.000000000000000,1761.000000000000000)
Pixel Size = (1.000000000000000,-1.000000000000000)
Image Structure Metadata:
   INTERLEAVE=BAND
Corner Coordinates:
Upper Left  (       0.000,    1761.000)
Lower Left  (   0.0000000,   1.0000000)
Upper Right (    2640.000,    1761.000)
Lower Right (    2640.000,       1.000)
Center      (    1320.000,     881.000)
Band 1 Block=2640x1 Type=Float32, ColorInterp=Gray


Could this be fixed?

Thanks,

Agus



More information about the R-sig-Geo mailing list