hex_area {ptools} | R Documentation |
Get area of hexagon given length of side
Description
The length of the side is half of the length from vertex to vertex (so height in geom_hex
).
Usage
hex_area(side)
Arguments
side |
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.
Value
A scaler for the width
See Also
hex_wd()
for estimating the width given the height
hex_dim()
for estimating width/height given area
Examples
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)
[Package ptools version 2.0.0 Index]