Skip to content
Uber's h3 bindings to the R Programming Language
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
R
man
src
.Rbuildignore
.gitignore
DESCRIPTION
NAMESPACE
README.md
h3r.Rproj

README.md

h3r

Uber's h3 geographical indexing library bindings for the R Programming Language.

What?

  • h3
  • It is a way to index coordinate data into hexagonal bins
  • So far, implemented methods help you
    • Convert coordinates to an index identifier (a unique ID for your hex)
    • Convert coordinates and index identifiers to a bounding hexagon

Usage

Prerequisites

  • h3. You'll need to follow the installation instructions.
  • Linux. I haven't tested the build on OSX but I don't expect it to work, and I'm pretty sure it won't work on Windows.

Examples

Houston <- list(lat = 29.7632836, lon = -95.3632715)

getIndexFromCoords(Houston$lat, Houston$lon, resolution = 5)
# [1] "85446cabfffffff"

hex <- getBoundingHexFromCoords(Houston$lat, Houston$lon, resolution = 5)
hexTib <- dplyr::bind_rows(hex)
hexTib
# # A tibble: 6 x 2
#        lat       lon
#      <dbl>     <dbl>
# 1 29.60453 -95.35630
# 2 29.67752 -95.28924
# 3 29.76643 -95.32811
# 4 29.78236 -95.43420
# 5 29.70931 -95.50129
# 6 29.62039 -95.46226

# We can plot the hex in leaflet
library(leaflet)
library(magrittr)
leaflet() %>% addTiles() %>% addPolygons(lng = hexTib$lon, lat = hexTib$lat)

# We can plot the hex in ggmap
library(ggmap)
ggmap(get_googlemap()) + geom_polygon(data = hexTib, mapping = aes(x = lon, y = lat))
You can’t perform that action at this time.