Skip to contents

This function creates a hexagon polygon based on the provided pair of center coordinates, size, and top type.

Usage

create_hexagon(center_x, center_y, size, top_type)

Arguments

center_x

The x-coordinate of the hexagon center.

center_y

The y-coordinate of the hexagon center.

size

The size of the hexagon. It should be based on projection of input data

top_type

The type of the hexagon top, either "flat" or "pointy".

Value

An 'sf' polygon representing the created hexagon.

Examples

# Create a flat-topped hexagon with center coordinates (419093.9, 3149336) and size 5km
flat_top <- create_hexagon(419093.9, 3149336, 50000, "flat")
# plot
plot((flat_top))

# create a pointy-topped hexagon with same arguments
pointy_top <- create_hexagon(419093.9, 3149336, 50000, "pointy")
# plot(pointy_top)