Skip to content

Latest commit

 

History

History
89 lines (64 loc) · 4.02 KB

geo-geohash-to-polygon-function.md

File metadata and controls

89 lines (64 loc) · 4.02 KB
title description ms.reviewer ms.topic ms.date
geo_geohash_to_polygon()
Learn how to use the geo_geohash_to_polygon() function to calculate the polygon that represents the geohash rectangular area.
mbrichko
reference
03/09/2023

geo_geohash_to_polygon()

Calculates the polygon that represents the geohash rectangular area.

Read more about geohash.

Syntax

geo_geohash_to_polygon(geohash)

[!INCLUDE syntax-conventions-note]

Parameters

Name Type Required Description
geohash string ✔️ A geohash value as it was calculated by geo_point_to_geohash(). The geohash string must be between 1 and 18 characters.

Returns

Polygon in GeoJSON Format and of a dynamic data type. If the geohash is invalid, the query will produce a null result.

Note

Geohash edges are straight lines and aren't geodesics. If the geohash polygon is part of some other calculation, consider densifying it with geo_polygon_densify().

Examples

[!div class="nextstepaction"] Run the query

print GeohashPolygon = geo_geohash_to_polygon("dr5ru");

Output

GeohashPolygon
{
"type": "Polygon",
"coordinates": [
[[-74.00390625, 40.7373046875], [-73.9599609375, 40.7373046875], [-73.9599609375, 40.78125], [-74.00390625, 40.78125], [-74.00390625, 40.7373046875]]]
}

The following example assembles GeoJSON geometry collection of geohash polygons.

[!div class="nextstepaction"] Run the query

// Geohash GeoJSON collection
datatable(lng:real, lat:real)
[
    -73.975212, 40.789608,
    -73.916869, 40.818314,
    -73.989148, 40.743273,
]
| project geohash = geo_point_to_geohash(lng, lat, 5)
| project geohash_polygon = geo_geohash_to_polygon(geohash)
| summarize geohash_polygon_lst = make_list(geohash_polygon)
| project bag_pack(
    "type", "Feature",
    "geometry", bag_pack("type", "GeometryCollection", "geometries", geohash_polygon_lst),
    "properties", bag_pack("name", "Geohash polygons collection"))

Output

Column1
{
"type": "Feature",
"geometry": {"type": "GeometryCollection","geometries": [
{"type": "Polygon", "coordinates": [[[-74.00390625, 40.78125], [-73.9599609375, 40.78125], [-73.9599609375, 40.8251953125],[ -74.00390625, 40.8251953125], [ -74.00390625, 40.78125]]]},
{"type": "Polygon", "coordinates": [[[ -73.9599609375, 40.78125], [-73.916015625, 40.78125], [-73.916015625, 40.8251953125], [-73.9599609375, 40.8251953125], [-73.9599609375, 40.78125]]]},
{"type": "Polygon", "coordinates": [[[-74.00390625, 40.7373046875], [-73.9599609375, 40.7373046875], [-73.9599609375, 40.78125], [-74.00390625, 40.78125], [-74.00390625, 40.7373046875]]]}]
},
"properties": {"name": "Geohash polygons collection"
}}

The following example returns a null result because of the invalid geohash input.

[!div class="nextstepaction"] Run the query

print GeohashPolygon = geo_geohash_to_polygon("a");

Output

GeohashPolygon