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 Thanks for the help. Cheers, Trevor [[alternative HTML version deleted]]
One place to start would be the "Spatial" task view on CRAN. The other would be to ask on R-sig-geo, where people who specialize in spatial data "hang out". Delaunay triangulation is available in several packages. A simple search for "delaunay" on the CRAN packages page will easily find at least one. You will also need the sp package for sure. Assigning a value to each triangle may or may not be easy, it will depend, probably among other things, on the data structure returned by whatever function you end up using to create the triangles. Based on a quick look at your acon web page, you might be happy with akima::interp Gridded Bivariate Interpolation for Irregular Data -Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 6/30/14 9:31 AM, "Trevor Davies" <davies.trevor at gmail.com> 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 > >Thanks for the help. >Cheers, >Trevor > > [[alternative HTML version deleted]] > >______________________________________________ >R-help at r-project.org mailing list >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide >http://www.R-project.org/posting-guide.html >and provide commented, minimal, self-contained, reproducible code.
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.htmlThe 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(). E.g.: set.seed(42) 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. cheers, Rolf Turner