# Single point conversion
(gh <- geohash_fwd(c(147.325, -42.881)))
geohash_rev(gh)
# Multiple points with varying precision
pts <- cbind(
lon = c(147, -74, 0),
lat = c(-42, 40.7, 51.5)
)
geohash_fwd(pts, len = c(6, 8, 12))
# Truncation preserves containment
gh <- geohash_fwd(c(147.325, -42.881), len = 12)
substr(gh, 1, 6) # Lower precision, but still contains original point
# Resolution for different lengths
geohash_resolution(1:12)
# Find length needed for ~1km precision
geohash_length(1/111) # ~1 degree / 111 km
Run the code above in your browser using DataLab