st_hexbin: Retrieve of set of hex-binned polygons for the given xyz data

View source: R/hexbin.R

st_hexbinR Documentation

Retrieve of set of hex-binned polygons for the given xyz data

Description

Retrieve of set of hex-binned polygons for the given xyz data

Usage

st_hexbin(
  x,
  y,
  z,
  fun = c("mean", "count", "median")[2],
  crs = ifelse(use_wkt("sf"), "epsg:4326",
    "+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0"),
  na.rm = TRUE,
  ...
)

Arguments

x

a vector of x-locations

y

a vector of y-locations

z

a vector of values associated with each location

fun

character the function used to process the cell values currently only 'mean', 'median', or 'count' (default)

crs

the projection string

na.rm

logical passed through to user's selected function

...

further arguments for hexbin

Value

a POLYGON sf data frame

See Also

hexbin docs

nice overview

Examples

## Not run: 
xyz <- hexbin_points()
 hb <- st_hexbin(xyz$x, xyz$y, xyz$z)
 hb <- dplyr::rename(hb, count = value)
 pts <- sf::st_as_sf(xyz,
                     coords = c("x", "y"),
                     crs = "+init=epsg:4326",
                     agr = "identity")
 plot(hb, asp = 1, reset = FALSE, axes = TRUE)
 plot(pts, col = 'green', add = TRUE)

## End(Not run)

BigelowLab/rasf documentation built on July 18, 2022, 10:19 p.m.