Skip to content

Instantly share code, notes, and snippets.

@cosh
Last active Jun 14, 2021
Embed
What would you like to do?
let k = dynamic({"type":"Polygon","coordinates":[[[-68.02734375,27.137368359795584],[-65.91796875,27.059125784374068],[-65.830078125,33.797408767572485],[-61.34765625,26.980828590472107],[-58.27148437499999,27.059125784374068],[-63.6328125,34.95799531086792],[-58.18359375,42.032974332441405],[-60.46875,42.09822241118974],[-65.91796875,34.95799531086792],[-65.91796875,42.16340342422401],[-68.115234375,42.032974332441405],[-68.02734375,27.137368359795584]]]});
let u = dynamic({"type":"Polygon","coordinates":[[[-53.0859375,27.137368359795584],[-50.2734375,27.137368359795584],[-47.548828125,28.3],[-46.40625,30],[-46.142578125,42.16340342422401],[-48.33984375,42.16340342422401],[-48.7,31],[-50.009765625,29.611670115197377],[-52.64648437499999,29.38217507514529],[-53.701171875,29.611670115197377],[-55.634765625,30.600093873550072],[-55.810546875,42.16340342422401],[-57.83203125,41.96765920367816],[-58.095703125,29.7],[-56.51367187499999,28.2],[-55.37109374999999,27.7],[-53.0859375,27.137368359795584]]]});
let s = dynamic({"type":"Polygon","coordinates":[[[-45.439453125,30.524413269923986],[-45.615234375,28.459033019728043],[-43.06640625,27.527758206861886],[-40.95703125,27.21555620902969],[-38.67187499999999,27.21555620902969],[-36.9140625,27.761329874505233],[-35.33203125,29.8],[-35.15625,31.203404950917395],[-36.826171875,33.9],[-39.19921875,34.9],[-41.1328125,35.5],[-42.5390625,36],[-43.06640625,37.50972584293751],[-42.71484375,38.89103282648846],[-40.341796875,40.111688665595956],[-38.14453125,40.17887331434696],[-36.2109375,39.70718665682654],[-35.33203125,38.95940879245423],[-35.15625,41.376808565702355],[-37.44140625,41.96765920367816],[-40.95703125,42.032974332441405],[-44.208984375,40.64730356252251],[-45.52734375,38.685509760012],[-45.703125,36.94989178681327],[-44.560546875,34.2],[-41.1328125,33],[-38.935546875,32.3],[-37.880859375,30.5],[-39.111328125,29.22889003019423],[-45.439453125,30.524413269923986]]]});
let t = dynamic({"type":"Polygon","coordinates":[[[-23.291015625,42.032974332441405],[-34.27734375,42.032974332441405],[-34.365234375,39.57182223734374],[-30.05859375,39.774769485295465],[-30.146484374999996,26.980828590472107],[-27.685546874999996,27.137368359795584],[-27.509765625,39.774769485295465],[-23.642578125,39.65],[-23.291015625,42.032974332441405]]]});
let o = dynamic({"type":"Polygon","coordinates":[[[-14.326171874999998,42.032974332441405],[-17.402343749999996,42.032974332441405],[-20.390625,41.1],[-21.97265625,39.8],[-22.763671875,37.50972584293751],[-22.587890625,30.977609093348686],[-21.357421875,28.613459424004414],[-18.45703125,27.605670826465445],[-16.875,27.137368359795584],[-15.205078125,26.980828590472107],[-12.65625,28],[-10.37109375,29.916852233070173],[-9.755859375,32.69486597787505],[-10.107421874999998,37.996162679728116],[-11.6015625,40.64730356252251],[-14.326171874999998,42.032974332441405]],[[-18.017578125,39.57182223734374],[-19.6875,37.64903402157866],[-19.423828125,32.10118973232094],[-17.578125,30.29701788337205],[-14.765625,29.99300228455108],[-13.0078125,31.27855085894653],[-13.271484375,37.92686760148135],[-15.292968749999998,39.639537564366684],[-18.017578125,39.57182223734374]]]});
range i from 1 to 100000 step 1
| project lng = rand() * real(-100), lat = rand() * 100
| where lng between(real(-68) .. real(-10)) and lat between(27 .. 42)
|summarize count() by hash = geo_point_to_h3cell(lng,lat, 3)
| extend p = geo_h3cell_to_central_point(hash)
| project lng = todouble(p.coordinates[0]), lat = todouble(p.coordinates[1]), ['hash']
| where geo_point_in_polygon(lng, lat, k) or geo_point_in_polygon(lng, lat, u) or geo_point_in_polygon(lng, lat, s) or geo_point_in_polygon(lng, lat, t) or geo_point_in_polygon(lng, lat, o)
| project ['hash']
| distinct ['hash']
| project geo_h3cell_to_polygon(['hash'])
| summarize make_list(Column1)
| project pack(
"type", "Feature",
"geometry", pack("type", "GeometryCollection", "geometries", list_Column1),
"properties", pack("name", "Kusto on the map"))
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment