tessellate: tessellate

Description Usage Arguments Value Examples

View source: R/tessellate.R

Description

Command line utility wrapper for the voro++ software library. voro++ must be installed on your system to use this function.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
tessellate(
  x,
  x_min = NA,
  x_max = NA,
  y_min = NA,
  y_max = NA,
  z_min = NA,
  z_max = NA,
  unit_scaling = c(1, 1, 1),
  output_definition = "%i*%P*%t",
  options = "-v",
  voro_path = "voro++"
)

Arguments

x

data.table/data.frame with the input points described by four variables (named columns):

  • id: id number that is passed to the output polygon (integer)

  • x: x-axis coordinate (numeric)

  • y: y-axis coordinate (numeric)

  • z: z-axis coordinate (numeric)

x_min

minimum x-axis coordinate of the tessellation box. Default: min(x). These values are automatically multiplied by the scaling factor in unit_scaling!

x_max

maximum x-axis coordinate of the tessellation box. Default: max(x)

y_min

minimum y-axis coordinate of the tessellation box. Default: min(y)

y_max

maximum y-axis coordinate of the tessellation box. Default: max(y)

z_min

minimum z-axis coordinate of the tessellation box. Default: min(z)

z_max

maximum z-axis coordinate of the tessellation box. Default: max(z)

unit_scaling

numeric vector with 3 scaling factors for x, y and z axis values. As a default setting (c(1,1,1)) tesselate assumes that the values given as x, y and z are comparable in units. If you input spatio-temporal data, make sure that you have units that determine your 3D distance metric the way you intend it to be. For example, if you need 1km=1year, use those units in the input. Otherwise, rescale appropriately. Mind that the values of *_min and *_max are adjusted as well by these factors. The unit_scaling parameter is stored as an attribute of the output to scale the output back automatically in read_polygon_edges.

output_definition

string that describes how the output file of voro++ should be structured. This is passed to the -c option of the command line interface. All possible customization options are documented here. Default: "%i*%P*%t"

options

string with additional options passed to voro++. All options are documented here. Default: "-v"

voro_path

system path to the voro++ executable. Default: "voro++"

Value

raw, linewise output of voro++ in a character vector with an attribute "unit scaling" (see above)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
random_unique_points <- unique(data.table::data.table(
  id = NA,
  x = runif(10, 0, 100000),
  y = runif(10, 0, 100000),
  z = runif(10, 0, 100)
))
random_unique_points$id <- seq_len(nrow(random_unique_points))

voro_output <- tessellate(random_unique_points, unit_scaling = c(0.001, 0.001, 1))

polygon_points <- read_polygon_edges(voro_output)

cut_surfaces <- cut_polygons(polygon_points, c(20, 40, 60))

cut_surfaces_sf <- cut_polygons_to_sf(cut_surfaces, crs = 25832)

polygons_z_20 <- sf::st_geometry(cut_surfaces_sf[cut_surfaces_sf$z == 20, ])
plot(polygons_z_20, col = sf::sf.colors(10, categorical = TRUE))

nevrome/bleiglas documentation built on Sept. 19, 2021, 3:12 p.m.