Shape data to work with the Geo package
- an s2_cell_id tag containing the S2 Cell ID as a token
- a field field containing the latitude in decimal degrees (WGS 84)
- a
lon
field field containing the longitude in decimal degrees (WGS 84)
If your data already contains latitude and longitude fields, use the to rename the fields to match the requirements of the Geo package, pivot the data into row-wise sets, and generate S2 cell ID tokens for each point.
Generate S2 cell ID tokens
The Geo package uses the to represent geographic coordinates on a three-dimensional sphere. The sphere is divided into cells, each with a unique 64-bit identifier (S2 cell ID). Grid and S2 cell ID accuracy are defined by a .
The Geo package requires S2 cell IDs as tokens. To generate add S2 cell IDs tokens to your data, use one of the following options:
Enable the Telegraf S2 Geo (s2geo) processor to generate S2 cell ID tokens at a specified cell_level
using lat
and field values.
Telegraf stores the S2 cell ID token in the s2_cell_id
tag.
Many programming languages offer S2 Libraries with methods for generating S2 cell ID tokens. Use latitude and longitude with the endpoint of the S2 Geometry Library to generate s2_cell_id
tags. For example:
- Go:
- Python: s2sphere.CellId.to_token()
- Crystal:
- JavaScript: s2.cellid.toToken()
The generates S2 cell ID tokens as well.