geo_point_to_h3cell()
Calculates the H3 Cell token string value of a geographic location.
Read more about H3 Cell.
Syntax
geo_point_to_h3cell(longitude, latitude, [ resolution ])
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| longitude | real | ✔️ | Geospatial coordinate, longitude value in degrees. Valid value is a real number and in the range [-180, +180]. |
| latitude | real | ✔️ | Geospatial coordinate, latitude value in degrees. Valid value is a real number and in the range [-90, +90]. |
| resolution | int | Defines the requested cell resolution. Supported values are in the range [0, 15]. If unspecified, the default value 6 is used. |
Returns
The H3 Cell token string value of a given geographic location. If the coordinates or levels are invalid, the query will produce an empty result.
H3 Cell approximate area coverage per resolution value
| Level | Average Hexagon Edge Length |
|---|---|
| 0 | 1108 km |
| 1 | 419 km |
| 2 | 158 km |
| 3 | 60 km |
| 4 | 23 km |
| 5 | 8 km |
| 6 | 3 km |
| 7 | 1 km |
| 8 | 460 m |
| 9 | 174 m |
| 10 | 66 m |
| 11 | 25 m |
| 12 | 9 m |
| 13 | 3 m |
| 14 | 1 m |
| 15 | 0.5 m |
The table source can be found in this H3 Cell statistical resource.
See also geo_point_to_s2cell(), geo_point_to_geohash().
Examples
print h3cell = geo_point_to_h3cell(-74.04450446039874, 40.689250859314974, 6)
Output
| h3cell |
|---|
| 862a1072fffffff |
The following example finds groups of coordinates. Every pair of coordinates in the group resides in the H3 Cell with average hexagon area of 253 km².
datatable(location_id:string, longitude:real, latitude:real)
[
"A", -73.956683, 40.807907,
"B", -73.916869, 40.818314,
"C", -73.989148, 40.743273,
]
| summarize count = count(), // Items per group count
locations = make_list(location_id) // Items in the group
by h3cell = geo_point_to_h3cell(longitude, latitude, 5) // H3 Cell of the group
Output
| h3cell | count | locations |
|---|---|---|
| 852a100bfffffff | 2 | [ “A”, “B” ] |
| 852a1073fffffff | 1 | [ “C” ] |
The following example produces an empty result because of the invalid coordinate input.
print h3cell = geo_point_to_h3cell(300,1,8)
Output
| h3cell |
|---|
The following example produces an empty result because of the invalid level input.
print h3cell = geo_point_to_h3cell(1,1,16)
Output
| h3cell |
|---|
The following example produces an empty result because of the invalid level input.
print h3cell = geo_point_to_h3cell(1,1,int(null))
Output
| h3cell |
|---|
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.