Hi,

The way I go about converting grid data to ascii grid text for loading into ArcGIS is to convert your SpatialGridDataFrame into a raster object (see the raster package for details) and then write to ascii using something along the lines of... 

library(maptools)
as(Im, "SpatialGridDataFrame")
# (as per  Michael Sumner's post)

library(raster)
writeRaster(raster(Im), filename=yourfilename.asc, format="ascii", NAflag=-9999)

Regards

Matt


----- Original Message -----
From: Honey-Marie de la Giroday <honeydelagiroday@gmail.com>
Date: Tuesday, July 12, 2011 8:56
Subject: [R-sig-Geo] Exporting spatstat 'pixel image' to Arcview 9.x as an	e00 or ascii
To: r-sig-geo@r-project.org

> Dear All,
> 
> I have a pixel image (im) I received as a .RData file.  I need to
> export this pixel image from R in a file format that can be imported
> into Arcview 9.x (e.g., .e00 or ascii).
> 
> Below is some of the code that I have been trying to use.  
> I have
> reviewed the manuals for rgdal, maptools, sp, and spatstat packages
> but have been unable to find another approach to converting the pixel
> image to an Arcview raster dataset.  Please note that I 
> have also
> searched the R-sig-geo archives and was unable to find this covered
> elsewhere.
> 
> "#load spatst package
> library(spatstat)
> 
> #load file with model data
> load(file="C:/bestmodel2004.RData")
> 
> #Plot best model data for 2004
> plot(bestmodel2004)
> 
> #Examine attributes of pixel image
> attributes(bestmodel2004)
> $names
>  [1] "v"      
> "dim"    "xrange" "yrange" "xstep"  
> "ystep"  "xcol"   "yrow"
>  [9] "type"   "units"
> 
> $class
> [1] "im"
> 
> #Load sp package
> library(sp)
> 
> #Coerce bestmodel2004 (pixel image) to SpatialGridDataFrame
> #......how do I do this?......
> 
> #Output to Acrview = write.asciigrid(x, fname, attr=1, na.value=-
> 9999.....#x=SpatialGridDataFrame
> #fname=filename
> write.asciigrid"
> 
> Thank you for your time, and please let me know if I need to provide
> further information.
> 
> Sincerely,
> 
> 
> 
> H.M.C de la Giroday
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Matthew Cracknell
PhD. Candidate
   
ARC Centre of Excellence in Ore Deposits
University of Tasmania
Private Bag 79
Hobart, 7001
Australia

Mob: 0409438924 



	[[alternative HTML version deleted]]

