[R-sig-Geo] Obtaining 3d surface area using polygon layer and DEM grid

Edzer Pebesma edzer.pebesma at uni-muenster.de
Wed Apr 14 17:38:37 CEST 2010


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 at 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 at wwu.de



More information about the R-sig-Geo mailing list