prep_hexgrid | R Documentation |
Creates hexagon grid cells of given area over particular study area.
prep_hexgrid(outline, area, clip_level = 0, point_over = NULL, point_n = 0)
outline |
SpatialPolygon or SpatialPolygonDataFrame that defines the area to draw hexgrid cells over |
area |
scaler for the area of the grid cells in whatever units the outline is in |
clip_level |
, you can clip grid cells if they are not entirely inside the outlined area, defaults to |
point_over |
default |
point_n |
default 0, only used if passing in |
This generates a vector hex grid over the study area of interest. Hexgrids are sometimes preferred over square grid cells to prevent aliasing like artifacts in maps (runs of particular values).
A SpatialPolygonDataFrame object with columns
id
, integer id value (not the same as row.names!)
x
, x centroid of grid cell
y
, y centroid of grid cell
cover
, optional (only if clip_level > 0) proportion that grid cell is covered by outline
count
, optional (only if you pass in point_over
), total N of points over
Circo, G. M., & Wheeler, A. P. (2021). Trauma Center Drive Time Distances and Fatal Outcomes among Gunshot Wound Victims. Applied Spatial Analysis and Policy, 14(2), 379-393.
library(sp) #for sp plot methods #Base example, some barely touch hnyc <- prep_hexgrid(nyc_bor,area=20000^2) plot(hnyc) plot(nyc_bor,border='red',add=TRUE) #Example clipping hexagons that have dongle hexagons hex_clip <- prep_hexgrid(nyc_bor,area=20000^2,clip_level=0.3) plot(hex_clip,border='blue') plot(nyc_bor,border='red',add=TRUE) summary(hnyc) #Example clipping hexagons with no overlap crimes hnyc <- prep_hexgrid(nyc_bor,area=4000^2,point_over=nyc_shoot) plot(hnyc) plot(nyc_shoot,pch='.',add=TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.