Learn R Programming

rollply (version 0.5.0)

build_grid_ahull_fill: Regular grid in alpha-hull

Description

Create a grid within the alpha hull of a set of points.

Usage

build_grid_ahull_fill(coords, npts, pad = NULL, grid_opts = list(alpha = 0.3, error_tol = 0.05, run_max = 20, verbose = FALSE))

Arguments

coords
A matrix or data.frame of coordinates with two columns
npts
The approximate number of points of the requested grid
pad
ignored argument
grid_opts
A list with component alpha, error_tol, run_max and verbose that controls the computation of the grid.

Value

The coordinates of a grid of points as a data.frame with approximately npts rows and ncol(coords) columns. Names are transfered from the coords data frame.

Details

This function computes the alpha hull of a set of points, then iteratively finds the best grid of npts points fitting in the hull.

This function computes the alpha hull of a set of points which is an estimate of its overall outline. The intricateness of this outline is determined by the alpha parameter: a value close to zero will produce a very intricate outline and a high value will produce a coarse outline (similar to the convex hull). It is highly recommended to try different values of alpha to see what is most appropriate for one's datasets. Parameter error_tol controls the acceptable relative error in the grid number of points (e.g. 0.1 for 10 control the iteration process.

See Also

ahull

Other grid.building.functions: build_grid_ahull_crop, build_grid_identical, build_grid_squaretile

Examples

Run this code

data(meadow)

# Plot a grid with diagnostics
grid <- build_grid_ahull_fill(meadow[ ,c('lon','lat')], 10000,
                              grid_opts = list(verbose = TRUE))
plot(grid, pch = 21)

# See the influence of alpha parameter
par(mfrow = c(1, 4))
for ( alpha in c( .3, 1, 4, 10) ) {
  grid <- build_grid_ahull_fill(meadow[ ,c('lon','lat')], 10000,
                                grid_opts = list(alpha = alpha))
  plot(grid, pch = 21)
  title(paste0("alpha=",alpha))
}

Run the code above in your browser using DataLab