geo_to_sf: Parse [lat, lng] points to object of class 'sf'

Description Usage Arguments Value Examples

View source: R/geo-to-sf.R

Description

Parse [lat, lng] points to object of class sf

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
geo_to_sf(lat_lng_obj)

## S3 method for class 'matrix'
geo_to_sf(lat_lng_obj)

## S3 method for class 'numeric'
geo_to_sf(lat_lng_obj)

## S3 method for class 'list'
geo_to_sf(lat_lng_obj)

Arguments

lat_lng_obj

numeric vector or matrix with [lat, lng] points as returned from h3_to_geo or h3_to_geo_boundary with format_as_geojson = FALSE; a list of matrices is also supported

Value

object of class sf (geometry type: POINT)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
coords <- c(37.3615593, -122.0553238)

h3_index <- geo_to_h3(coords, 7)
h3_indexes <- k_ring(h3_index)

# Single center point
h3_to_geo(h3_index) %>% geo_to_sf()

# Multiple center points
h3_to_geo(h3_indexes) %>% geo_to_sf()

# Boundary points (single hexagon)
h3_to_geo_boundary(h3_index, format_as_geojson = FALSE) %>%
  geo_to_sf()

# Boundary points (multiple hexagons)
h3_to_geo_boundary(h3_indexes, format_as_geojson = FALSE) %>%
  geo_to_sf()

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