I've generated a number of plots using the
stat_summary_hex functions in
ggplot2, and I've adjusted the number of bins until the plot "looked right." That said, I'd like to know the area each bin represents to help interpret the plot.
Below is a simplified example of the set of example data and plot:
library(dplyr) library(ggplot2) library(rgeos) library(maptools) library(rgdal) library(hexbin) crime <-read.csv("https://opendata.arcgis.com/datasets/6eaf3e9713de44d3aa103622d51053b5_9.csv", stringsAsFactors = F) homicides <- crime %>% dplyr::select(long = ï..X, lat = Y, OFFENSE) %>% filter(OFFENSE == "HOMICIDE") coordinates(homicides) <- ~long + lat homicides.df <- data.frame(homicides) homicides.hex <- ggplot() + geom_hex(data = homicides.df, aes(x=long, y =lat), fun = sum, bins = 20) + coord_equal() print(homicides.hex)
Is there a function or method to measure the area (in square miles or kilometers) of an individual hexagon when the x and y axes are latitude and longitude?