Skip to content

ascii-grid export

1 message · Barry Rowlingson

#
On Mon, Nov 4, 2013 at 7:27 AM, Enzo Cocca <enzo.ccc at gmail.com> wrote:
Why do you want to make an ascii-grid out of this? The variogram map
isn't in geographical coordinates, its in coordinate differences in x
and y

The return value when map=TRUE doesn't seem to be too well documented,
but looks like it is a list with a 'map' element that is a spatial
pixels data frame. Here's an example using the demo data (I can't run
your code because I don't have your data, please try and make your
problems easily reproducible):

require(sp)
require(gstat)
data(meuse)
coordinates(meuse)=~x+y
v=variogram(log(zinc)~1, meuse,map=TRUE,cutoff=900,width=10)
class(v$map)
[1] "SpatialPixelsDataFrame"
attr(,"package")
[1] "sp"

Now that can be written using rgdal's writeGDAL function.

However, you need the AAIGrid driver to work properly:
Error in .local(.Object, ...) : Dataset copy failed

raster package to the rescue:
class       : RasterLayer

[etc]

When I look at the file, I have an ESRI grid file:

$ head -5 v.asc
NCOLS 181
NROWS 181
XLLCORNER -905
YLLCORNER -905
CELLSIZE 10
[+ data]

Now, that's assuming you wanted to write the data, not a pretty image
picture like you get when you plot the variogram map. And there's
still the mystery of why you want to write a non-geographic
coordinate-based dataset to a geographic data format...

 And you should probably have asked this on R-sig-geo where the
geographRs (including the authors of gstat) hang out.

 Hope this helps anyway.

Barry