geo_to_h3: Get all hexagons containing [lat, lng] points

Description Usage Arguments Value Examples

View source: R/h3_geo-to-h3.R

Description

Get all hexagons containing [lat, lng] points

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
geo_to_h3(coords, res = 7)

## S3 method for class 'numeric'
geo_to_h3(coords, res = 7)

## S3 method for class 'matrix'
geo_to_h3(coords, res = 7)

## S3 method for class 'data.frame'
geo_to_h3(coords, res = 7)

## S3 method for class 'sf'
geo_to_h3(coords, res = 7)

Arguments

coords

numeric vector, matrix or data.frame with [lat, lng] pairs; object of class sf (geometry type: POINT)

res

resolution of hexagons to return; number between 0 and 15

Value

H3 indexes; character vector

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# numeric
coords <- c(37.3615593, -122.0553238)
geo_to_h3(coords, 7)

# matrix
geo_to_h3(road_safety_greater_manchester[1:10, ], res = 5)

# sf
points <- as.data.frame(greater_manchester) %>%
  sf::st_as_sf(coords = c("lng", "lat"), crs = 4326)
geo_to_h3(points[1:5, ], res = 12)

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