grid2polygon: Create polygons from gridded points

View source: R/flownet_plotting.R

grid2polygonR Documentation

Create polygons from gridded points

Description

Get the node indices of the four corner points of a series of grids

Usage

grid2polygon(df, dp)

Arguments

df

list with flownet problem definition

dp

list with flownet results, per node. This dataframe should contain a field with the name 'val' that is used to calculate a value for each polygon

Value

tibble with polygon data. Unique polygons are differentiated using the unique identifier in the field 'id'. Interpolated values are stored in field 'val', and the positions of the corner points in 'x' and 'y'

Examples

#calculate
df <- flownet_geometry_rectangular(grid_size = 2)
dp <- flownet_solve_rectangular(df)
dpol <- grid2polygon(df, dp)

#plot
ggplot2::ggplot() +
  ggplot2::geom_polygon(
    data = dpol,
    ggplot2::aes(x = x, y = y, fill = h, group = id),
    color = NA
  )

GJMeijer/soilmech documentation built on May 22, 2022, 10:39 a.m.