Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get geotiff image

Tags:

r

I want to have a Geotiff image in R.How can I do that? Following is a simple example. I want to have the produced plot in Geotiff format.

require(gstat)
data(meuse)
coordinates(meuse) = ~x+y
data(meuse.grid)
gridded(meuse.grid) = ~x+y
m <- vgm(.59, "Sph", 874, .04)
# ordinary kriging:
x <- krige(log(zinc)~1, meuse, meuse.grid, model = m)
spplot(x["var1.pred"], main = "ordinary kriging predictions")
like image 792
Mona Eshraghi Avatar asked Dec 17 '12 07:12

Mona Eshraghi


1 Answers

Convert your SpatialPixelsDataFrame to a raster and write it:

> require(raster)
> r = raster(x["var1.pred"])
> plot(r)
> writeRaster(r,"r.tiff","GTiff")

The plot is optional.

like image 93
Spacedman Avatar answered Sep 27 '22 21:09

Spacedman