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

Agustin Lobo alobolistas at gmail.com
Wed Aug 29 21:14:52 CEST 2012


As Hyperion images are too large to be processed as common R arrays,
you must use the raster package by R. Hijmans. This package creates an
small special R object
that includes the characteristics of your image but points to the
actual file on disk,
thus no overloading your RAM.
Processing is done through dedicated functions in raster.

Agus


On Tue, Aug 28, 2012 at 2:27 PM, cpadwick <cpadwick at hotmail.com> wrote:
> 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.
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo



More information about the R-sig-Geo mailing list