[R-sig-Geo] write.asciigrid

Andy Bunn abunn at whrc.org
Fri May 5 18:54:58 CEST 2006


> -----Original Message-----
> From: Roger Bivand [mailto:Roger.Bivand at nhh.no]
> Sent: Friday, May 05, 2006 12:29 PM
> To: Andy Bunn
> Cc: Zev Ross; r-sig-geo at stat.math.ethz.ch
> Subject: RE: [R-sig-Geo] write.asciigrid
>
>
> On Fri, 5 May 2006, Andy Bunn wrote:
>
> > > > I second Roger's recommendation for using rgdal. I've been
> > > writing to and
> > > > fro from img files with few problems. The only problem I have
> > > with ArcGIS is
> > > > that the statistics have had to be recalculated in Arc for
> > > floats to get the
> > > > display to work correctly. But, Arc has a batch statistics tool
> > > that doesn't
> > > > crash often (when a tool works reliably in Arc I'm
> surprised and pleased
> > > > beyond reason). Keep up the good work Roger, Tim, Edzer and all the
> > > > rest. -Andy
> > >
> > > Thanks for this input, Andy. Could you please flesh it out a little,
> > > perhaps a run through from SpatialPixels/GridDataFrame to
> inside ArcGIS
> > > (version?)? I'll try too, but if you have a well-trodden path ...
> >
> >     library(sp)
> >     library(rgdal)
> >     data(meuse.grid)
> >     coordinates(meuse.grid) = c("x", "y") # promote to
> > SpatialPointsDataFrame
> >     gridded(meuse.grid) <- TRUE # promote to SpatialPixelsDataFrame
> >     image(meuse.grid["dist"])
> >     writeGDAL(meuse.grid,"c:/data/research/tmp/meuse.grid.img",
> > driver="HFA")
> >
> > Arc can display this img file without issue if the statistics are
> > reclaculated using the Calculate Statistics under Raster. Note
> the lack of
> > projcetion however!
>
> Which ArcGIS version, please, and the exact (TM) steps you took -
> I've got
> a kriging prediction *.img, but haven't got any further (sorry, my Arc
> abilities are limited) - I don't "see" any Calculate Statistics or Raster
> anywhere (and Arc just crashed, probably latency to the license server).

It's ArcGIS 9.1 (Build 750). The statistics tool is in ArcToolbox | Data
Management Tools | Raster | Calculate Statistics (There is also a Batch
Calculate Statistics tool). This can be scripted too and done from R using
system (?). Scripts can be written in any COM-compliant scripting language
(Python, JScript, or VBScript) and run directly from within the scripting
application. Here is a script example that could be wrapped into an sp
function, I suppose:

    from win32com.client import Dispatch
    gp = Dispatch('esriGeoprocessing.GpDispatch.1')
    gp.workspace = "c:/data/research/tmp"
    # calculate stats with skip factor of 1,1, and ignore value of 0
    gp.CalculateStatistics("meuse.grid.img","1","1","0")

-Andy

> Roger
>
> >
> > -Andy
> >
>
> --
> Roger Bivand
> Economic Geography Section, Department of Economics, Norwegian School of
> Economics and Business Administration, Helleveien 30, N-5045 Bergen,
> Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
> e-mail: Roger.Bivand at nhh.no
>
>




More information about the R-sig-Geo mailing list