[R-sig-Geo] problems writing a tiff file with georeferencing

cpadwick cpadwick at hotmail.com
Tue Aug 28 14:27:29 CEST 2012


Hi, I want to read an existing geotiff file (with georeferencing info),
operate on the raster data, and write out the result to a Float32 file.  I'm
working with hyperion data which is Integer.

This code creates an outputfile, however, the output file t1.tif is Integer. 
I need it to be float.

fname = "./EO1H0420362001131100P1/EO1H0420362001131100P1_B023_L1T.TIF"
x <- GDAL.open(fname, read.only=TRUE)
tmp = getRasterData(x)
xx <- copyDataset(x, driver="GTiff")
putRasterData(xx, tmp+1)
saveDataset(xx, "t1.tif")
GDAL.close(x)
GDAL.close(xx)

This code creates a Float32 file, however, the geo referencing information
is lost:

x <- GDAL.open(fname, read.only=TRUE)
tmp = getRasterData(x)
xx <- new("GDALTransientDataset", driver=new("GDALDriver", "GTiff"), 
  rows=ncol(tmp), cols=nrow(tmp), bands=1, type="Float32")
putRasterData(xx, tmp+1)
saveDataset(xx, "t2.tif")
GDAL.close(x)
GDAL.close(xx)

This code fails with the following error:

Error in function (classes, fdef, mtable)  : 
  unable to find an inherited method for function "gridded", for signature
"GDALTransientDataset"

x <- GDAL.open(fname, read.only=TRUE)
tmp = getRasterData(x)
xx <- copyDataset(x, driver="GTiff")
putRasterData(xx, tmp+1)
writeGDAL(xx, "t3.tif")
GDAL.close(x)
GDAL.close(xx)

Any help will be greatly appreciated.






--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/problems-writing-a-tiff-file-with-georeferencing-tp7580850.html
Sent from the R-sig-geo mailing list archive at Nabble.com.



More information about the R-sig-Geo mailing list