Learn R Programming

ptools (version 2.0.0)

hex_dim: Get dimensions of hexagon given area

Description

Get dimensions of hexagon given area

Usage

hex_dim(area)

Value

a vector with two elements, first element is the height (vertex to vertex), the second element is the width (side to side)

Arguments

area

scaler

Details

For use with ggplot and geom_hex binwidth arguments, which expects arguments in width/height. I want hexagons in maps to be a specific area. See this blog post for a specific use case with ggplot.

See Also

hex_wd() for estimating the width given the height hex_area() for estimating the area given side length

Examples

Run this code
area_check <- 1000
wh <- hex_dim(area_check^2)   #e.g. a square kilometer if spatial units are in meters
area <- hex_area(wh[1]/2)       #inverse operation
all.equal(area_check,sqrt(area))
wi <- hex_wd(wh[1])
all.equal(wh[2],wi)

Run the code above in your browser using DataLab