olctools (version 0.3.0)

recover_olc: Recover Full Open Location Codes From Shortened Codes

Description

shorten_olc (and other sources) shorten a code, reducing the space it occupies. They also limit its ability to be translated back into latitude/longitude pairs. recover_olc recovers a full code from a shortened one, allowing it to be decoded with decode_olc. Some loss of accuracy or precision is expected - and as it finds the closest match to the coordinates rather than to the original code, the characters may be very different.

Usage

recover_olc(olcs, lats, longs)

Arguments

olcs
a vector of short open location codes, generated with shorten_olc or through any other means.
lats
a numeric vector of latitudes.
longs
a numeric vector of longitudes, equivalent in size to lats.

Examples

Run this code
# Shorten an OLC and then recover the nearest full code. Note the actual characters differ.
shortened_code <- shorten_olc("8FVC9G8F+6X", 47.5, 8.5);
recovered_code <- recover_olc(shortened_code, 47.4, 8.6);

Run the code above in your browser using DataLab