Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Decode Google polyline strings into coordinate locations
ResourceFunction["GooglePolylineDecode"][str] decodes the polyline string str and returns the corresponding GeoPosition(s). |
Decode a polyline string representing a single location:
| In[1]:= |
| Out[1]= |
Decode a polyline string representing a route containing many locations:
| In[2]:= |
| Out[2]= |
The "?" character indicates a zero value for latitude/longitude:
| In[3]:= |
| Out[3]= |
| In[4]:= |
| Out[4]= |
| In[5]:= |
| Out[5]= |
If the polyline string contains information for only one coordinate, a single number is returned:
| In[6]:= |
| Out[6]= |
If a polyline is incomplete, i.e. the number of latitudes and longitudes are unequal, an error is returned:
| In[9]:= |
The following completes the polyline above by including a second latitude:
| In[10]:= |
| Out[10]= |
If a polyline is insufficient to express a coordinate, the same error is returned:
| In[11]:= |
If a polyline is incomplete but the 'remainder' after the complete section of the string is insufficient to express a coordinate, the locations of the complete section are returned:
| In[12]:= |
| Out[12]= |
Decode a polyline representing a hike up Scafell Pike, Lake District, UK:
| In[13]:= | ![]() |
| Out[10]= | ![]() |
This work is licensed under a Creative Commons Attribution 4.0 International License