[R] geotiff or tiff files with world files

Roger Bivand Roger.Bivand at nhh.no
Thu Sep 6 12:32:55 CEST 2007


Monica Pisica <pisicandru <at> hotmail.com> writes:

> 
> 
> Hi,
> 
> I have a matrix of data which i can vizualize as an image - for example.
> I would like to save this image as a
> geotiff file or at a tiff file with a world file which holds the projection
> of my data (ultimately the data
> represent a map of some sort). I know i can save the data as an ESRI
> grid, but i am not interested in that.
> 
> I wonder if anybody knows about any code which will help me do that.

See the writeGDAL() function in the rgdal package, and hints on how to 
turn your matrix into a SpatialGridDataFrame object in the sp package. 
For example:

data(volcano)
str(volcano)
image(volcano)
grd <- GridTopology(c(0.5, 0.5), c(1, 1), c(87, 61))
SGDF <- SpatialGridDataFrame(grd, data=data.frame(volcano=c(volcano)))
image(SGDF, "volcano")

See the proj4string= argument to insert the projection in valid PROJ.4 
format. Then:

writeGDAL(SGDF, "volcano.tif", drivername = "GTiff", ...)

using the options= id needed, to pass through create options as on:

http://www.gdal.org/frmt_gtiff.html

For follow-ups, please consider the R-sig-geo list.

Roger

> 
> Thanks in advance,
> 
> Monica
> _________________________________________________________________
> 
> s. It's easy!
> 
> aspx&mkt=en-us
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help <at> stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
>



More information about the R-help mailing list