gh_encode: Geohash encoding

Description Usage Arguments Details Value Author(s) References Examples

View source: R/gh_encode.R

Description

Convert latitude/longitude coordinates into geohash-encoded strings

Usage

1
gh_encode(latitude, longitude, precision = 6L)

Arguments

latitude

numeric vector of input latitude (y) coordinates. Must be in [-90, 90).

longitude

numeric vector of input longitude (x) coordinates. Should be in [-180, 180).

precision

Positive integer scalar controlling the 'zoom level' – how many characters should be used in the output.

Details

precision is limited to at most 28. This level of precision encodes locations on the globe at a nanometer scale and is already more than enough for basically all applications.

Longitudes outside [-180, 180) will be wrapped appropriately to the standard longitude grid.

Value

character vector of geohashes corresponding to the input. NA in gives NA out.

Author(s)

Michael Chirico

References

http://geohash.org/ ( Gustavo Niemeyer's original geohash service )

Examples

1
2
3
4
5
6
# scalar input is treated as a vector
gh_encode(2.345, 6.789)

# geohashes are left-closed, right-open, so boundary coordinates are
#   associated to the east and/or north
gh_encode(0, 0)

geohashTools documentation built on July 1, 2020, 7:09 p.m.