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")
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With