buffer_points_linear: Buffer points linear

Description Usage Arguments Examples

View source: R/custom_buffer-points-linear.R

Description

Weight is calculated as 1 - distance / (1 + radius).

Usage

1
buffer_points_linear(points, radius = 2, res = 8)

Arguments

points

matrix, data frame or object of class sf with POINT geometry

radius

number of rings (used as buffer around points)

res

resolution of hexagons to return

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
library(sf)
library(leaflet)

bart_stations <- system.file("geojson/bart_stations.geojson", package = "h3forr") %>%
  st_read(quiet = TRUE)

buffer <- buffer_points_linear(bart_stations, radius = 2, res = 8)
hexagons <- h3_to_geo_boundary(buffer$h3_index) %>% geo_boundary_to_sf()

pal <- colorNumeric("Blues", buffer$norm)

map <- leaflet() %>% addTiles() %>%
  addPolygons(
    data = hexagons,
    fillOpacity = 0.9,
    fillColor = pal(buffer$norm),
    weight = 1,
    color = "white",
    label = sprintf("%s", buffer$norm)
  ) %>%
  addMarkers(data = bart_stations)

if (interactive()) map

crazycapivara/h3forr documentation built on Dec. 6, 2020, 5:21 a.m.