[R] Delaunay triangles with LONG/LAT + biomass

Rolf Turner r.turner at auckland.ac.nz
Tue Jul 1 00:29:57 CEST 2014

On 01/07/14 04:31, Trevor Davies wrote:
> Hello,
> I was hoping someone could point me in the direction towards a package
> where I can use delaunay triangulation to create a polygon set where the
> inside of the triangles are tagged with an estimate of a mean value of the
> points making up the points of the triangle.  This is fisheries trawl data
> if that helps add context.
> For those familiar with the system, it's to make plots similar to those
> made by the Dept of Fisheries and Oceans Canada in ACON (which has now
> stopped being maintained).  Although freely available, I'm on a mac and it
> would be nice to just get it sorted out in R going forward.
> Ref here:
> http://www2.mar.dfo-mpo.gc.ca/science/acon/Examples/ShadedContours.html

The deldir package has the capacity to tag points with values, and the 
triang.list() function creates a list of data frames corresponding to 
each triangle, the last column of these data frames (named "z") being 
the "values" associated with the corners of the triangles.

The means of these values can be calculated using sapply().


x <- runif(20)
y <- runif(20)
z <- sample(1:5,20,TRUE)
dxy <- deldir(x,y,z=z)
txy <- triang.list(dxy)
mxy <- sapply(txy,function(u){mean(u[["z"]])})

You could "tag" the triangles with these mean values by assigning the 
values as attributes of the components of txy, using lapply(), possibly.

Note that deldir() treats coordinates as ***Euclidean*** coordinates. 
This is only an approximation to a triangulation on a sphere.  Whether 
the approximation is good enough is up to you, I guess.


Rolf Turner

More information about the R-help mailing list