Thanks you Barry and Edzer for your replies! 

I should have mentioned that I'm a relatively new to spatial analysis in R, and unfortunately I'm not familiar with programing in C. But I'm ready to learn! In trying to understand the code below, I see that you are generating a 2000x2000 matrix with a random uniform number then using the function sacalc, but how is it calculating the 3d surface (I tried the web for documentation on sacalc but didn't get too far... )? Would that be the equivalent of getting a DEM clipped by the polygon of interest and then running it through sacalc?

Maybe I should wait a bit longer for Edzer to integrate it into sp... :>)  I'll be happy to put it to the test with my bear home range data and compare results to the Jenness tool in ArcView, as I will have to do so for my analyses anyway.

Thanks again,
Sharon
 
Sharon Baruch-Mordo
Ph.D. Candidate in Ecology
Dept. of Fish, Wildlife, and Conservation Biology
Colorado State University
Fort Collins, CO 80523-1474
Phone: 970-491-7020  
Fax: 970-491-5091
E-mail: sharonbm@warnercnr.colostate.edu
http://www.warnercnr.colostate.edu/research/bear





________________________________
From: Edzer Pebesma <edzer.pebesma@uni-muenster.de>
To: Barry Rowlingson <b.rowlingson@lancaster.ac.uk>

Sent: Wed, April 14, 2010 9:38:37 AM
Subject: Re: [R-sig-Geo] Obtaining 3d surface area using polygon layer and DEM grid

Barry, I wouldn't object integrating it in sp. Can it cope with missing
values in the grid? Would you be willing to write a short help file with
some reference to the algorithm used? (I found this one:
http://www.jennessent.com/downloads/WSB_32_3_Jenness.pdf )

Barry Rowlingson wrote:
> On Tue, Apr 13, 2010 at 5:46 PM, Barry Rowlingson
> <b.rowlingson@lancaster.ac.uk> wrote:
> 
>>  I don't know of any R implementation of a surface area algorithm for
>> R at the moment.
> 
>  Well, I do now because I've just written it. It's an implementation
> of the Jenness algorithm. He doesn't say how he copes with the edges,
> so what I do is extend the grid by 1 pixel all round and fill the edge
> with the nearest value from the grid.
> 
>  It's written in C and does a 2000x2000 grid in a couple of seconds.
> 
>  > b=matrix(runif(2000*2000),2000,2000)
>  > system.time(print(sacalc(b)))
>  [1] 4592546
>    user  system elapsed
>    1.868  0.076  1.941
> 
>  now currently it doesn't take into account the grid spacing - it
> assumes the cells are 1 unit apart and that's the same scale as the
> values. Simple enough to add scaling but fiddly to integrate it into
> SpatialGrid objects. Matrices are so much simpler :)

That's why SpatialGridDataFrames have an as.matrix method. Of course you
loose the cell size.

> 
>  Also, it's one C file and one R file, no documentation, and I've not
> tested it hardly, and I can't build it for Windows.
> 
> Barry
> 

-- 
Edzer Pebesma
Institute for Geoinformatics (ifgi), University of Münster
Weseler Straße 253, 48151 Münster, Germany. Phone: +49 251
8333081, Fax: +49 251 8339763  http://ifgi.uni-muenster.de
http://www.52north.org/geostatistics      e.pebesma@wwu.de



      
	[[alternative HTML version deleted]]

