gh_decode: Geohash decoding

Description Usage Arguments Details Value Author(s) References Examples

View source: R/gh_decode.R

Description

Convert geohash-encoded strings into latitude/longitude coordinates

Usage

1
gh_decode(geohashes, include_delta = FALSE, coord_loc = 'c')

Arguments

geohashes

character or factor vector or of input geohashes. There's no need for all inputs to be of the same precision.

include_delta

logical; should the cell half-width delta be included in the output?

coord_loc

character specifying where in the cell points should be mapped to; cell centroid is mapped by default; case-insensitive. See Details.

Details

coord_loc can be the cell's center ('c' or 'centroid'), or it can be any of the 8 corners (e.g. 's'/'south' for the midpoint of the southern boundary of the cell, or 'ne'/'northeast' for the upper-right corner.

For factor input, decoding will be done on the levels for efficiency.

Value

list with the following entries:

latitude

numeric vector of latitudes (y-coordinates) corresponding to the input geohashes, with within-cell position dictated by coord_loc

longitude

numeric vector of longitudes (x-coordinates) corresponding to the input geohashes, with within-cell position dictated by coord_loc

delta_latitude

numeric vector of cell half-widths in the y direction (only included if include_delta is TRUE

delta_longitude

numeric vector of cell half-widths in the x direction (only included if include_delta is TRUE

Author(s)

Michael Chirico

References

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

Examples

1
2
3
4
5
# Riddle me this
gh_decode('stq4s8c')

# Cell half-widths might be convenient to include for downstream analysis
gh_decode('tjmd79', include_delta = TRUE)

Example output

sh: 1: cannot create /dev/null: Permission denied
$latitude
[1] 29.97551

$longitude
[1] 31.13731

$latitude
[1] 29.935

$longitude
[1] 52.89368

$delta_latitude
[1] 0.002746582

$delta_longitude
[1] 0.005493164

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