On Thu, 8 Mar 2007, Paul Magdon wrote:
Hello,
I'm using R for classifying remote sensed data. I finally managed to apply
different knn-methods to the data. Now I have a Dataframe with X, Y, and Z
columns.
Exp.:
X Y Z
475477.1 7485303.29 46.62
Is there an easy way to export such dataframe into am Esri compatible
format like Arcgrid, img, tiff etc.??
Yes, for example:
library(sp)
data(meuse.grid)
class(meuse.grid)
names(meuse.grid)
coordinates(meuse.grid) <- c("x", "y")
class(meuse.grid)
gridded(meuse.grid) <- TRUE
class(meuse.grid)
fullgrid(meuse.grid) <- TRUE
class(meuse.grid)
library(rgdal)
writeGDAL(meuse.grid["dist"], "dist.tif", drivername="GTiff")
This of course will not work if the points are not regularly spaced;
there are plenty of different drivers for GDAL. For OSX either install
rgdal on GDAL/PROJ.4 from source (see Rgeo site linked from Spatial Task
View on CRAN for details) or write an Arc ASCII grid using
writeAsciiGrid() in the maptools package, which does not depend on
external libraries.
Roger