Learn R Programming

geohash (version 0.3.0)

gh_encode: Encode Latitude and Longitude Values

Description

gh_encode generates geohashes of a given precision from vectors of latitude and longitude values.

Usage

gh_encode(lats, lngs, precision = 6L)

Arguments

lats

a numeric vector of latitude values.

lngs

a numeric vector of longitude values. Must be the same length as lat.

precision

an integer representing the precision the hashes should have. This should be between 1 and 10; if the precision requested is greater than 10, it will use 10 - if less than 1, it will error.

Value

a character vector of hashes, the same length as lat and lng, with NA values where one of the equivalent lat/lng pair was NA.

See Also

gh_decode, for taking geohashes and turning them back into coordinates, and gh_neighbours for retrieving the neighbouring hashes to a particular hash.

Examples

Run this code
# NOT RUN {
# A simple example:
gh_encode(lat = 42.60498046875, lng = -5.60302734375, precision = 5)
#[1] "ezs42"

# }

Run the code above in your browser using DataLab