{"id":13426336,"url":"https://github.com/uber/h3-js","last_synced_at":"2025-06-11T17:39:45.388Z","repository":{"id":37789028,"uuid":"132669533","full_name":"uber/h3-js","owner":"uber","description":"h3-js provides a JavaScript version of H3, a hexagon-based geospatial indexing system.","archived":false,"fork":false,"pushed_at":"2025-03-10T18:53:10.000Z","size":1541,"stargazers_count":906,"open_issues_count":11,"forks_count":82,"subscribers_count":26,"default_branch":"master","last_synced_at":"2025-03-10T19:43:16.082Z","etag":null,"topics":["emscripten","geospatial","h3","hexagon","javascript","spatial-indexing","uber"],"latest_commit_sha":null,"homepage":"https://uber.github.io/h3","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/uber.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-05-08T21:57:08.000Z","updated_at":"2025-03-10T18:53:15.000Z","dependencies_parsed_at":"2023-02-11T23:00:25.982Z","dependency_job_id":"a32c4a7d-745e-413d-a181-37141c99d81b","html_url":"https://github.com/uber/h3-js","commit_stats":{"total_commits":261,"total_committers":12,"mean_commits":21.75,"dds":0.5708812260536398,"last_synced_commit":"0a5704e746a67a54a6f33f7afdf9e20421be5636"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uber%2Fh3-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uber%2Fh3-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uber%2Fh3-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uber%2Fh3-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/uber","download_url":"https://codeload.github.com/uber/h3-js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243792343,"owners_count":20348626,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["emscripten","geospatial","h3","hexagon","javascript","spatial-indexing","uber"],"created_at":"2024-07-31T00:01:32.211Z","updated_at":"2025-03-15T21:31:08.167Z","avatar_url":"https://github.com/uber.png","language":"JavaScript","readme":"\u003c!-- the README is generated from a template, please edit doc-files/README.md.tmpl --\u003e\n\n\u003cimg align=\"right\" src=\"https://uber.github.io/img/h3Logo-color.svg\" alt=\"H3 Logo\" width=\"200\"\u003e\n\n# h3-js\n\n[![Build Status](https://github.com/uber/h3-js/workflows/test/badge.svg)](https://github.com/uber/h3-js/actions)\n[![Coverage Status](https://coveralls.io/repos/github/uber/h3-js/badge.svg?branch=master)](https://coveralls.io/github/uber/h3-js?branch=master)\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE)\n[![npm version](https://badge.fury.io/js/h3-js.svg)](https://badge.fury.io/js/h3-js)\n[![H3 Version](https://img.shields.io/static/v1?label=h3%20api\u0026message=v4.1.0\u0026color=blue)](https://github.com/uber/h3/releases/tag/v4.1.0)\n\nThe `h3-js` library provides a pure-JavaScript version of the [H3 Core Library](https://github.com/uber/h3), a hexagon-based geographic grid system. It can be used either in Node \u003e= 6 or in the browser. The core library is transpiled from C using [emscripten](http://kripken.github.io/emscripten-site), offering full parity with the C API and highly efficient operations.\n\nFor more information on H3 and for the full API documentation, please see the [H3 Documentation](https://h3geo.org).\n\n-   Post **bug reports or feature requests** to the [Github Issues page](https://github.com/uber/h3-js/issues)\n-   Ask **questions** by posting to the [H3 tag on StackOverflow](https://stackoverflow.com/questions/tagged/h3)\n\n## Install\n\n    npm install h3-js\n\n## Usage\n\n\u003e :tada: **Note:** The following usage docs apply to **H3 v4**, which was released on August 23, 2022.\n\u003e\n\u003e - For v3 docs, [see the latest v3.x.x release](https://github.com/uber/h3-js/blob/v3.7.2/README.md).\n\u003e - For breaking changes in v4, [see the CHANGELOG](./CHANGELOG.md). In particular, most [function names have changed](https://h3geo.org/docs/library/migration-3.x/functions).\n\nThe library uses ES6 modules. Bundles for Node and the browser are built to the `dist` folder.\n\n### Import\n\nES6 usage:\n\n```js\nimport {latLngToCell} from \"h3-js\";\n```\n\nCommonJS usage:\n\n```js\nconst h3 = require(\"h3-js\");\n```\n\nPre-bundled script (library is available as an `h3` global):\n\n```html\n\u003cscript src=\"https://unpkg.com/h3-js\"\u003e\u003c/script\u003e\n```\n\n### Core functions\n\n```js\n// Convert a lat/lng point to a hexagon index at resolution 7\nconst h3Index = h3.latLngToCell(37.3615593, -122.0553238, 7);\n// -\u003e '87283472bffffff'\n\n// Get the center of the hexagon\nconst hexCenterCoordinates = h3.cellToLatLng(h3Index);\n// -\u003e [37.35171820183272, -122.05032565263946]\n\n// Get the vertices of the hexagon\nconst hexBoundary = h3.cellToBoundary(h3Index);\n// -\u003e [ [37.341099093235684, -122.04156135164334 ], ...]\n```\n\n### Useful algorithms\n\n```js\n// Get all neighbors within 1 step of the hexagon\nconst disk = h3.gridDisk(h3Index, 1);\n// -\u003e ['87283472bffffff', '87283472affffff', ...]\n\n// Get the set of hexagons within a polygon\nconst polygon = [\n    [37.813318999983238, -122.4089866999972145],\n    [37.7198061999978478, -122.3544736999993603],\n    [37.8151571999998453, -122.4798767000009008]\n];\nconst hexagons = h3.polygonToCells(polygon, 7);\n// -\u003e ['872830828ffffff', '87283082effffff', ...]\n\n// Get the outline of a set of hexagons, as a GeoJSON-style MultiPolygon\nconst coordinates = h3.cellsToMultiPolygon(hexagons, true);\n// -\u003e [[[\n//      [-122.37681938644465, 37.76546768434345],\n//      [-122.3856345540363,37.776004200673846],\n//      ...\n//    ]]]\n```\n\n## API Reference\n\n\u003ca name=\"module_h3\"\u003e\u003c/a\u003e\n\n## h3\n\n* [h3](#module_h3)\n    * [.UNITS](#module_h3.UNITS)\n    * [.POLYGON_TO_CELLS_FLAGS](#module_h3.POLYGON_TO_CELLS_FLAGS)\n    * [.h3IndexToSplitLong(h3Index)](#module_h3.h3IndexToSplitLong) ⇒ \u003ccode\u003eSplitLong\u003c/code\u003e\n    * [.splitLongToH3Index(lower, upper)](#module_h3.splitLongToH3Index) ⇒ \u003ccode\u003eH3Index\u003c/code\u003e\n    * [.isValidCell(h3Index)](#module_h3.isValidCell) ⇒ \u003ccode\u003eboolean\u003c/code\u003e\n    * [.isPentagon(h3Index)](#module_h3.isPentagon) ⇒ \u003ccode\u003eboolean\u003c/code\u003e\n    * [.isResClassIII(h3Index)](#module_h3.isResClassIII) ⇒ \u003ccode\u003eboolean\u003c/code\u003e\n    * [.getBaseCellNumber(h3Index)](#module_h3.getBaseCellNumber) ⇒ \u003ccode\u003enumber\u003c/code\u003e\n    * [.getIcosahedronFaces(h3Index)](#module_h3.getIcosahedronFaces) ⇒ \u003ccode\u003eArray.\u0026lt;number\u0026gt;\u003c/code\u003e\n    * [.getResolution(h3Index)](#module_h3.getResolution) ⇒ \u003ccode\u003enumber\u003c/code\u003e\n    * [.latLngToCell(lat, lng, res)](#module_h3.latLngToCell) ⇒ \u003ccode\u003eH3Index\u003c/code\u003e\n    * [.cellToLatLng(h3Index)](#module_h3.cellToLatLng) ⇒ \u003ccode\u003eCoordPair\u003c/code\u003e\n    * [.cellToBoundary(h3Index, [formatAsGeoJson])](#module_h3.cellToBoundary) ⇒ \u003ccode\u003eArray.\u0026lt;CoordPair\u0026gt;\u003c/code\u003e\n    * [.cellToParent(h3Index, res)](#module_h3.cellToParent) ⇒ \u003ccode\u003eH3Index\u003c/code\u003e\n    * [.cellToChildren(h3Index, res)](#module_h3.cellToChildren) ⇒ \u003ccode\u003eArray.\u0026lt;H3Index\u0026gt;\u003c/code\u003e\n    * [.cellToChildrenSize(h3Index, res)](#module_h3.cellToChildrenSize) ⇒ \u003ccode\u003enumber\u003c/code\u003e\n    * [.cellToCenterChild(h3Index, res)](#module_h3.cellToCenterChild) ⇒ \u003ccode\u003eH3Index\u003c/code\u003e\n    * [.cellToChildPos(h3Index, parentRes)](#module_h3.cellToChildPos) ⇒ \u003ccode\u003enumber\u003c/code\u003e\n    * [.childPosToCell(childPos, h3Index, childRes)](#module_h3.childPosToCell) ⇒ \u003ccode\u003eH3Index\u003c/code\u003e\n    * [.gridDisk(h3Index, ringSize)](#module_h3.gridDisk) ⇒ \u003ccode\u003eArray.\u0026lt;H3Index\u0026gt;\u003c/code\u003e\n    * [.gridDiskDistances(h3Index, ringSize)](#module_h3.gridDiskDistances) ⇒ \u003ccode\u003eArray.\u0026lt;Array.\u0026lt;H3Index\u0026gt;\u0026gt;\u003c/code\u003e\n    * [.gridRingUnsafe(h3Index, ringSize)](#module_h3.gridRingUnsafe) ⇒ \u003ccode\u003eArray.\u0026lt;H3Index\u0026gt;\u003c/code\u003e\n    * [.polygonToCells(coordinates, res, [isGeoJson])](#module_h3.polygonToCells) ⇒ \u003ccode\u003eArray.\u0026lt;H3Index\u0026gt;\u003c/code\u003e\n    * [.polygonToCellsExperimental(coordinates, res, flags, [isGeoJson])](#module_h3.polygonToCellsExperimental) ⇒ \u003ccode\u003eArray.\u0026lt;H3Index\u0026gt;\u003c/code\u003e\n    * [.cellsToMultiPolygon(h3Indexes, [formatAsGeoJson])](#module_h3.cellsToMultiPolygon) ⇒ \u003ccode\u003eArray.\u0026lt;Array.\u0026lt;Array.\u0026lt;CoordPair\u0026gt;\u0026gt;\u0026gt;\u003c/code\u003e\n    * [.compactCells(h3Set)](#module_h3.compactCells) ⇒ \u003ccode\u003eArray.\u0026lt;H3Index\u0026gt;\u003c/code\u003e\n    * [.uncompactCells(compactedSet, res)](#module_h3.uncompactCells) ⇒ \u003ccode\u003eArray.\u0026lt;H3Index\u0026gt;\u003c/code\u003e\n    * [.areNeighborCells(origin, destination)](#module_h3.areNeighborCells) ⇒ \u003ccode\u003eboolean\u003c/code\u003e\n    * [.cellsToDirectedEdge(origin, destination)](#module_h3.cellsToDirectedEdge) ⇒ \u003ccode\u003eH3Index\u003c/code\u003e\n    * [.getDirectedEdgeOrigin(edgeIndex)](#module_h3.getDirectedEdgeOrigin) ⇒ \u003ccode\u003eH3Index\u003c/code\u003e\n    * [.getDirectedEdgeDestination(edgeIndex)](#module_h3.getDirectedEdgeDestination) ⇒ \u003ccode\u003eH3Index\u003c/code\u003e\n    * [.isValidDirectedEdge(edgeIndex)](#module_h3.isValidDirectedEdge) ⇒ \u003ccode\u003eboolean\u003c/code\u003e\n    * [.directedEdgeToCells(edgeIndex)](#module_h3.directedEdgeToCells) ⇒ \u003ccode\u003eArray.\u0026lt;H3Index\u0026gt;\u003c/code\u003e\n    * [.originToDirectedEdges(h3Index)](#module_h3.originToDirectedEdges) ⇒ \u003ccode\u003eArray.\u0026lt;H3Index\u0026gt;\u003c/code\u003e\n    * [.directedEdgeToBoundary(edgeIndex, [formatAsGeoJson])](#module_h3.directedEdgeToBoundary) ⇒ \u003ccode\u003eArray.\u0026lt;CoordPair\u0026gt;\u003c/code\u003e\n    * [.gridDistance(origin, destination)](#module_h3.gridDistance) ⇒ \u003ccode\u003enumber\u003c/code\u003e\n    * [.gridPathCells(origin, destination)](#module_h3.gridPathCells) ⇒ \u003ccode\u003eArray.\u0026lt;H3Index\u0026gt;\u003c/code\u003e\n    * [.cellToLocalIj(origin, destination)](#module_h3.cellToLocalIj) ⇒ \u003ccode\u003eCoordIJ\u003c/code\u003e\n    * [.localIjToCell(origin, coords)](#module_h3.localIjToCell) ⇒ \u003ccode\u003eH3Index\u003c/code\u003e\n    * [.greatCircleDistance(latLng1, latLng2, unit)](#module_h3.greatCircleDistance) ⇒ \u003ccode\u003enumber\u003c/code\u003e\n    * [.cellArea(h3Index, unit)](#module_h3.cellArea) ⇒ \u003ccode\u003enumber\u003c/code\u003e\n    * [.edgeLength(edge, unit)](#module_h3.edgeLength) ⇒ \u003ccode\u003enumber\u003c/code\u003e\n    * [.getHexagonAreaAvg(res, unit)](#module_h3.getHexagonAreaAvg) ⇒ \u003ccode\u003enumber\u003c/code\u003e\n    * [.getHexagonEdgeLengthAvg(res, unit)](#module_h3.getHexagonEdgeLengthAvg) ⇒ \u003ccode\u003enumber\u003c/code\u003e\n    * [.cellToVertex(h3Index, vertexNum)](#module_h3.cellToVertex) ⇒ \u003ccode\u003eH3Index\u003c/code\u003e\n    * [.cellToVertexes(h3Index)](#module_h3.cellToVertexes) ⇒ \u003ccode\u003eArray.\u0026lt;H3Index\u0026gt;\u003c/code\u003e\n    * [.vertexToLatLng(h3Index)](#module_h3.vertexToLatLng) ⇒ \u003ccode\u003eCoordPair\u003c/code\u003e\n    * [.isValidVertex(h3Index)](#module_h3.isValidVertex) ⇒ \u003ccode\u003eboolean\u003c/code\u003e\n    * [.getNumCells(res)](#module_h3.getNumCells) ⇒ \u003ccode\u003enumber\u003c/code\u003e\n    * [.getRes0Cells()](#module_h3.getRes0Cells) ⇒ \u003ccode\u003eArray.\u0026lt;H3Index\u0026gt;\u003c/code\u003e\n    * [.getPentagons(res)](#module_h3.getPentagons) ⇒ \u003ccode\u003eArray.\u0026lt;H3Index\u0026gt;\u003c/code\u003e\n    * [.degsToRads(deg)](#module_h3.degsToRads) ⇒ \u003ccode\u003enumber\u003c/code\u003e\n    * [.radsToDegs(rad)](#module_h3.radsToDegs) ⇒ \u003ccode\u003enumber\u003c/code\u003e\n    * [.H3Index](#module_h3.H3Index) : \u003ccode\u003estring\u003c/code\u003e\n    * [.H3IndexInput](#module_h3.H3IndexInput) : \u003ccode\u003estring\u003c/code\u003e \\| \u003ccode\u003eArray.\u0026lt;number\u0026gt;\u003c/code\u003e\n    * [.CoordIJ](#module_h3.CoordIJ)\n    * [.H3Error](#module_h3.H3Error)\n    * [.CoordPair](#module_h3.CoordPair) : \u003ccode\u003eArray.\u0026lt;number\u0026gt;\u003c/code\u003e\n    * [.SplitLong](#module_h3.SplitLong) : \u003ccode\u003eArray.\u0026lt;number\u0026gt;\u003c/code\u003e\n\n\n* * *\n\n\u003ca name=\"module_h3.UNITS\"\u003e\u003c/a\u003e\n\n### h3.UNITS\nLength/Area units\n\n**Properties**\n\n| Name | Type |\n| --- | --- |\n| m | \u003ccode\u003estring\u003c/code\u003e | \n| m2 | \u003ccode\u003estring\u003c/code\u003e | \n| km | \u003ccode\u003estring\u003c/code\u003e | \n| km2 | \u003ccode\u003estring\u003c/code\u003e | \n| rads | \u003ccode\u003estring\u003c/code\u003e | \n| rads2 | \u003ccode\u003estring\u003c/code\u003e | \n\n\n* * *\n\n\u003ca name=\"module_h3.POLYGON_TO_CELLS_FLAGS\"\u003e\u003c/a\u003e\n\n### h3.POLYGON\\_TO\\_CELLS\\_FLAGS\nMode flags for polygonToCells\n\n**Properties**\n\n| Name | Type |\n| --- | --- |\n| containmentCenter | \u003ccode\u003estring\u003c/code\u003e | \n| containmentFull | \u003ccode\u003estring\u003c/code\u003e | \n| containmentOverlapping | \u003ccode\u003estring\u003c/code\u003e | \n| containmentOverlappingBbox | \u003ccode\u003estring\u003c/code\u003e | \n\n\n* * *\n\n\u003ca name=\"module_h3.h3IndexToSplitLong\"\u003e\u003c/a\u003e\n\n### h3.h3IndexToSplitLong(h3Index) ⇒ \u003ccode\u003eSplitLong\u003c/code\u003e\nConvert an H3 index (64-bit hexidecimal string) into a \"split long\" - a pair of 32-bit ints\n\n**Returns**: \u003ccode\u003eSplitLong\u003c/code\u003e - A two-element array with 32 lower bits and 32 upper bits  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| h3Index | \u003ccode\u003eH3IndexInput\u003c/code\u003e | H3 index to check |\n\n\n* * *\n\n\u003ca name=\"module_h3.splitLongToH3Index\"\u003e\u003c/a\u003e\n\n### h3.splitLongToH3Index(lower, upper) ⇒ \u003ccode\u003eH3Index\u003c/code\u003e\nGet a H3 index string from a split long (pair of 32-bit ints)\n\n**Returns**: \u003ccode\u003eH3Index\u003c/code\u003e - H3 index  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| lower | \u003ccode\u003enumber\u003c/code\u003e | Lower 32 bits |\n| upper | \u003ccode\u003enumber\u003c/code\u003e | Upper 32 bits |\n\n\n* * *\n\n\u003ca name=\"module_h3.isValidCell\"\u003e\u003c/a\u003e\n\n### h3.isValidCell(h3Index) ⇒ \u003ccode\u003eboolean\u003c/code\u003e\nWhether a given string represents a valid H3 index\n\n**Returns**: \u003ccode\u003eboolean\u003c/code\u003e - Whether the index is valid  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| h3Index | \u003ccode\u003eH3IndexInput\u003c/code\u003e | H3 index to check |\n\n\n* * *\n\n\u003ca name=\"module_h3.isPentagon\"\u003e\u003c/a\u003e\n\n### h3.isPentagon(h3Index) ⇒ \u003ccode\u003eboolean\u003c/code\u003e\nWhether the given H3 index is a pentagon\n\n**Returns**: \u003ccode\u003eboolean\u003c/code\u003e - isPentagon  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| h3Index | \u003ccode\u003eH3IndexInput\u003c/code\u003e | H3 index to check |\n\n\n* * *\n\n\u003ca name=\"module_h3.isResClassIII\"\u003e\u003c/a\u003e\n\n### h3.isResClassIII(h3Index) ⇒ \u003ccode\u003eboolean\u003c/code\u003e\nWhether the given H3 index is in a Class III resolution (rotated versus\nthe icosahedron and subject to shape distortion adding extra points on\nicosahedron edges, making them not true hexagons).\n\n**Returns**: \u003ccode\u003eboolean\u003c/code\u003e - isResClassIII  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| h3Index | \u003ccode\u003eH3IndexInput\u003c/code\u003e | H3 index to check |\n\n\n* * *\n\n\u003ca name=\"module_h3.getBaseCellNumber\"\u003e\u003c/a\u003e\n\n### h3.getBaseCellNumber(h3Index) ⇒ \u003ccode\u003enumber\u003c/code\u003e\nGet the number of the base cell for a given H3 index\n\n**Returns**: \u003ccode\u003enumber\u003c/code\u003e - Index of the base cell (0-121)  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| h3Index | \u003ccode\u003eH3IndexInput\u003c/code\u003e | H3 index to get the base cell for |\n\n\n* * *\n\n\u003ca name=\"module_h3.getIcosahedronFaces\"\u003e\u003c/a\u003e\n\n### h3.getIcosahedronFaces(h3Index) ⇒ \u003ccode\u003eArray.\u0026lt;number\u0026gt;\u003c/code\u003e\nGet the indices of all icosahedron faces intersected by a given H3 index\n\n**Returns**: \u003ccode\u003eArray.\u0026lt;number\u0026gt;\u003c/code\u003e - Indices (0-19) of all intersected faces  \n**Throws**:\n\n- \u003ccode\u003eH3Error\u003c/code\u003e If input is invalid\n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| h3Index | \u003ccode\u003eH3IndexInput\u003c/code\u003e | H3 index to get faces for |\n\n\n* * *\n\n\u003ca name=\"module_h3.getResolution\"\u003e\u003c/a\u003e\n\n### h3.getResolution(h3Index) ⇒ \u003ccode\u003enumber\u003c/code\u003e\nReturns the resolution of an H3 index\n\n**Returns**: \u003ccode\u003enumber\u003c/code\u003e - The number (0-15) resolution, or -1 if invalid  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| h3Index | \u003ccode\u003eH3IndexInput\u003c/code\u003e | H3 index to get resolution |\n\n\n* * *\n\n\u003ca name=\"module_h3.latLngToCell\"\u003e\u003c/a\u003e\n\n### h3.latLngToCell(lat, lng, res) ⇒ \u003ccode\u003eH3Index\u003c/code\u003e\nGet the hexagon containing a lat,lon point\n\n**Returns**: \u003ccode\u003eH3Index\u003c/code\u003e - H3 index  \n**Throws**:\n\n- \u003ccode\u003eH3Error\u003c/code\u003e If input is invalid\n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| lat | \u003ccode\u003enumber\u003c/code\u003e | Latitude of point |\n| lng | \u003ccode\u003enumber\u003c/code\u003e | Longtitude of point |\n| res | \u003ccode\u003enumber\u003c/code\u003e | Resolution of hexagons to return |\n\n\n* * *\n\n\u003ca name=\"module_h3.cellToLatLng\"\u003e\u003c/a\u003e\n\n### h3.cellToLatLng(h3Index) ⇒ \u003ccode\u003eCoordPair\u003c/code\u003e\nGet the lat,lon center of a given hexagon\n\n**Returns**: \u003ccode\u003eCoordPair\u003c/code\u003e - Point as a [lat, lng] pair  \n**Throws**:\n\n- \u003ccode\u003eH3Error\u003c/code\u003e If input is invalid\n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| h3Index | \u003ccode\u003eH3IndexInput\u003c/code\u003e | H3 index |\n\n\n* * *\n\n\u003ca name=\"module_h3.cellToBoundary\"\u003e\u003c/a\u003e\n\n### h3.cellToBoundary(h3Index, [formatAsGeoJson]) ⇒ \u003ccode\u003eArray.\u0026lt;CoordPair\u0026gt;\u003c/code\u003e\nGet the vertices of a given hexagon (or pentagon), as an array of [lat, lng]\npoints. For pentagons and hexagons on the edge of an icosahedron face, this\nfunction may return up to 10 vertices.\n\n**Returns**: \u003ccode\u003eArray.\u0026lt;CoordPair\u0026gt;\u003c/code\u003e - Array of [lat, lng] pairs  \n**Throws**:\n\n- \u003ccode\u003eH3Error\u003c/code\u003e If input is invalid\n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| h3Index | \u003ccode\u003eH3IndexInput\u003c/code\u003e | H3 index |\n| [formatAsGeoJson] | \u003ccode\u003eboolean\u003c/code\u003e | Whether to provide GeoJSON output: [lng, lat], closed loops |\n\n\n* * *\n\n\u003ca name=\"module_h3.cellToParent\"\u003e\u003c/a\u003e\n\n### h3.cellToParent(h3Index, res) ⇒ \u003ccode\u003eH3Index\u003c/code\u003e\nGet the parent of the given hexagon at a particular resolution\n\n**Returns**: \u003ccode\u003eH3Index\u003c/code\u003e - H3 index of parent, or null for invalid input  \n**Throws**:\n\n- \u003ccode\u003eH3Error\u003c/code\u003e If input is invalid\n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| h3Index | \u003ccode\u003eH3IndexInput\u003c/code\u003e | H3 index to get parent for |\n| res | \u003ccode\u003enumber\u003c/code\u003e | Resolution of hexagon to return |\n\n\n* * *\n\n\u003ca name=\"module_h3.cellToChildren\"\u003e\u003c/a\u003e\n\n### h3.cellToChildren(h3Index, res) ⇒ \u003ccode\u003eArray.\u0026lt;H3Index\u0026gt;\u003c/code\u003e\nGet the children/descendents of the given hexagon at a particular resolution\n\n**Returns**: \u003ccode\u003eArray.\u0026lt;H3Index\u0026gt;\u003c/code\u003e - H3 indexes of children, or empty array for invalid input  \n**Throws**:\n\n- \u003ccode\u003eH3Error\u003c/code\u003e If resolution is invalid or output is too large for JS\n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| h3Index | \u003ccode\u003eH3IndexInput\u003c/code\u003e | H3 index to get children for |\n| res | \u003ccode\u003enumber\u003c/code\u003e | Resolution of hexagons to return |\n\n\n* * *\n\n\u003ca name=\"module_h3.cellToChildrenSize\"\u003e\u003c/a\u003e\n\n### h3.cellToChildrenSize(h3Index, res) ⇒ \u003ccode\u003enumber\u003c/code\u003e\nGet the number of children for a cell at a given resolution\n\n**Returns**: \u003ccode\u003enumber\u003c/code\u003e - Number of children at res for the given cell  \n**Throws**:\n\n- \u003ccode\u003eH3Error\u003c/code\u003e If cell or parentRes are invalid\n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| h3Index | \u003ccode\u003eH3IndexInput\u003c/code\u003e | H3 index to get child count for |\n| res | \u003ccode\u003enumber\u003c/code\u003e | Child resolution |\n\n\n* * *\n\n\u003ca name=\"module_h3.cellToCenterChild\"\u003e\u003c/a\u003e\n\n### h3.cellToCenterChild(h3Index, res) ⇒ \u003ccode\u003eH3Index\u003c/code\u003e\nGet the center child of the given hexagon at a particular resolution\n\n**Returns**: \u003ccode\u003eH3Index\u003c/code\u003e - H3 index of child, or null for invalid input  \n**Throws**:\n\n- \u003ccode\u003eH3Error\u003c/code\u003e If resolution is invalid\n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| h3Index | \u003ccode\u003eH3IndexInput\u003c/code\u003e | H3 index to get center child for |\n| res | \u003ccode\u003enumber\u003c/code\u003e | Resolution of cell to return |\n\n\n* * *\n\n\u003ca name=\"module_h3.cellToChildPos\"\u003e\u003c/a\u003e\n\n### h3.cellToChildPos(h3Index, parentRes) ⇒ \u003ccode\u003enumber\u003c/code\u003e\nGet the position of the cell within an ordered list of all children of the\ncell's parent at the specified resolution.\n\n**Returns**: \u003ccode\u003enumber\u003c/code\u003e - Position of child within parent at parentRes  \n**Throws**:\n\n- \u003ccode\u003eH3Error\u003c/code\u003e If cell or parentRes are invalid\n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| h3Index | \u003ccode\u003eH3IndexInput\u003c/code\u003e | H3 index to get child pos for |\n| parentRes | \u003ccode\u003enumber\u003c/code\u003e | Resolution of reference parent |\n\n\n* * *\n\n\u003ca name=\"module_h3.childPosToCell\"\u003e\u003c/a\u003e\n\n### h3.childPosToCell(childPos, h3Index, childRes) ⇒ \u003ccode\u003eH3Index\u003c/code\u003e\nGet the child cell at a given position within an ordered list of all children\nat the specified resolution\n\n**Returns**: \u003ccode\u003eH3Index\u003c/code\u003e - H3 index of child  \n**Throws**:\n\n- \u003ccode\u003eH3Error\u003c/code\u003e If input is invalid\n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| childPos | \u003ccode\u003enumber\u003c/code\u003e | Position of the child cell to get |\n| h3Index | \u003ccode\u003eH3IndexInput\u003c/code\u003e | H3 index of the parent cell |\n| childRes | \u003ccode\u003enumber\u003c/code\u003e | Resolution of child cell to return |\n\n\n* * *\n\n\u003ca name=\"module_h3.gridDisk\"\u003e\u003c/a\u003e\n\n### h3.gridDisk(h3Index, ringSize) ⇒ \u003ccode\u003eArray.\u0026lt;H3Index\u0026gt;\u003c/code\u003e\nGet all hexagons in a k-ring around a given center. The order of the hexagons is undefined.\n\n**Returns**: \u003ccode\u003eArray.\u0026lt;H3Index\u0026gt;\u003c/code\u003e - H3 indexes for all hexagons in ring  \n**Throws**:\n\n- \u003ccode\u003eH3Error\u003c/code\u003e If input is invalid or output is too large for JS\n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| h3Index | \u003ccode\u003eH3IndexInput\u003c/code\u003e | H3 index of center hexagon |\n| ringSize | \u003ccode\u003enumber\u003c/code\u003e | Radius of k-ring |\n\n\n* * *\n\n\u003ca name=\"module_h3.gridDiskDistances\"\u003e\u003c/a\u003e\n\n### h3.gridDiskDistances(h3Index, ringSize) ⇒ \u003ccode\u003eArray.\u0026lt;Array.\u0026lt;H3Index\u0026gt;\u0026gt;\u003c/code\u003e\nGet all hexagons in a k-ring around a given center, in an array of arrays\nordered by distance from the origin. The order of the hexagons within each ring is undefined.\n\n**Returns**: \u003ccode\u003eArray.\u0026lt;Array.\u0026lt;H3Index\u0026gt;\u0026gt;\u003c/code\u003e - Array of arrays with H3 indexes for all hexagons each ring  \n**Throws**:\n\n- \u003ccode\u003eH3Error\u003c/code\u003e If input is invalid or output is too large for JS\n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| h3Index | \u003ccode\u003eH3IndexInput\u003c/code\u003e | H3 index of center hexagon |\n| ringSize | \u003ccode\u003enumber\u003c/code\u003e | Radius of k-ring |\n\n\n* * *\n\n\u003ca name=\"module_h3.gridRingUnsafe\"\u003e\u003c/a\u003e\n\n### h3.gridRingUnsafe(h3Index, ringSize) ⇒ \u003ccode\u003eArray.\u0026lt;H3Index\u0026gt;\u003c/code\u003e\nGet all hexagons in a hollow hexagonal ring centered at origin with sides of a given length.\nUnlike gridDisk, this function will throw an error if there is a pentagon anywhere in the ring.\n\n**Returns**: \u003ccode\u003eArray.\u0026lt;H3Index\u0026gt;\u003c/code\u003e - H3 indexes for all hexagons in ring  \n**Throws**:\n\n- \u003ccode\u003eError\u003c/code\u003e If the algorithm could not calculate the ring\n- \u003ccode\u003eH3Error\u003c/code\u003e If input is invalid\n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| h3Index | \u003ccode\u003eH3IndexInput\u003c/code\u003e | H3 index of center hexagon |\n| ringSize | \u003ccode\u003enumber\u003c/code\u003e | Radius of ring |\n\n\n* * *\n\n\u003ca name=\"module_h3.polygonToCells\"\u003e\u003c/a\u003e\n\n### h3.polygonToCells(coordinates, res, [isGeoJson]) ⇒ \u003ccode\u003eArray.\u0026lt;H3Index\u0026gt;\u003c/code\u003e\nGet all hexagons with centers contained in a given polygon. The polygon\nis specified with GeoJson semantics as an array of loops. Each loop is\nan array of [lat, lng] pairs (or [lng, lat] if isGeoJson is specified).\nThe first loop is the perimeter of the polygon, and subsequent loops are\nexpected to be holes.\n\n**Returns**: \u003ccode\u003eArray.\u0026lt;H3Index\u0026gt;\u003c/code\u003e - H3 indexes for all hexagons in polygon  \n**Throws**:\n\n- \u003ccode\u003eH3Error\u003c/code\u003e If input is invalid or output is too large for JS\n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| coordinates | \u003ccode\u003eArray.\u0026lt;Array.\u0026lt;number\u0026gt;\u0026gt;\u003c/code\u003e \\| \u003ccode\u003eArray.\u0026lt;Array.\u0026lt;Array.\u0026lt;number\u0026gt;\u0026gt;\u0026gt;\u003c/code\u003e | Array of loops, or a single loop |\n| res | \u003ccode\u003enumber\u003c/code\u003e | Resolution of hexagons to return |\n| [isGeoJson] | \u003ccode\u003eboolean\u003c/code\u003e | Whether to expect GeoJson-style [lng, lat]                                  pairs instead of [lat, lng] |\n\n\n* * *\n\n\u003ca name=\"module_h3.polygonToCellsExperimental\"\u003e\u003c/a\u003e\n\n### h3.polygonToCellsExperimental(coordinates, res, flags, [isGeoJson]) ⇒ \u003ccode\u003eArray.\u0026lt;H3Index\u0026gt;\u003c/code\u003e\nGet all hexagons with centers contained in a given polygon. The polygon\nis specified with GeoJson semantics as an array of loops. Each loop is\nan array of [lat, lng] pairs (or [lng, lat] if isGeoJson is specified).\nThe first loop is the perimeter of the polygon, and subsequent loops are\nexpected to be holes.\n\n**Returns**: \u003ccode\u003eArray.\u0026lt;H3Index\u0026gt;\u003c/code\u003e - H3 indexes for all hexagons in polygon  \n**Throws**:\n\n- \u003ccode\u003eH3Error\u003c/code\u003e If input is invalid or output is too large for JS\n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| coordinates | \u003ccode\u003eArray.\u0026lt;Array.\u0026lt;number\u0026gt;\u0026gt;\u003c/code\u003e \\| \u003ccode\u003eArray.\u0026lt;Array.\u0026lt;Array.\u0026lt;number\u0026gt;\u0026gt;\u0026gt;\u003c/code\u003e | Array of loops, or a single loop |\n| res | \u003ccode\u003enumber\u003c/code\u003e | Resolution of hexagons to return |\n| flags | \u003ccode\u003estring\u003c/code\u003e | Value from POLYGON_TO_CELLS_FLAGS |\n| [isGeoJson] | \u003ccode\u003eboolean\u003c/code\u003e | Whether to expect GeoJson-style [lng, lat]                                  pairs instead of [lat, lng] |\n\n\n* * *\n\n\u003ca name=\"module_h3.cellsToMultiPolygon\"\u003e\u003c/a\u003e\n\n### h3.cellsToMultiPolygon(h3Indexes, [formatAsGeoJson]) ⇒ \u003ccode\u003eArray.\u0026lt;Array.\u0026lt;Array.\u0026lt;CoordPair\u0026gt;\u0026gt;\u0026gt;\u003c/code\u003e\nGet the outlines of a set of H3 hexagons, returned in GeoJSON MultiPolygon\nformat (an array of polygons, each with an array of loops, each an array of\ncoordinates). Coordinates are returned as [lat, lng] pairs unless GeoJSON\nis requested.\n\nIt is the responsibility of the caller to ensure that all hexagons in the\nset have the same resolution and that the set contains no duplicates. Behavior\nis undefined if duplicates or multiple resolutions are present, and the\nalgorithm may produce unexpected or invalid polygons.\n\n**Returns**: \u003ccode\u003eArray.\u0026lt;Array.\u0026lt;Array.\u0026lt;CoordPair\u0026gt;\u0026gt;\u0026gt;\u003c/code\u003e - MultiPolygon-style output.  \n**Throws**:\n\n- \u003ccode\u003eH3Error\u003c/code\u003e If input is invalid\n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| h3Indexes | \u003ccode\u003eArray.\u0026lt;H3IndexInput\u0026gt;\u003c/code\u003e | H3 indexes to get outlines for |\n| [formatAsGeoJson] | \u003ccode\u003eboolean\u003c/code\u003e | Whether to provide GeoJSON output: [lng, lat], closed loops |\n\n\n* * *\n\n\u003ca name=\"module_h3.compactCells\"\u003e\u003c/a\u003e\n\n### h3.compactCells(h3Set) ⇒ \u003ccode\u003eArray.\u0026lt;H3Index\u0026gt;\u003c/code\u003e\nCompact a set of hexagons of the same resolution into a set of hexagons across\nmultiple levels that represents the same area.\n\n**Returns**: \u003ccode\u003eArray.\u0026lt;H3Index\u0026gt;\u003c/code\u003e - Compacted H3 indexes  \n**Throws**:\n\n- \u003ccode\u003eH3Error\u003c/code\u003e If the input is invalid (e.g. duplicate hexagons)\n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| h3Set | \u003ccode\u003eArray.\u0026lt;H3IndexInput\u0026gt;\u003c/code\u003e | H3 indexes to compact |\n\n\n* * *\n\n\u003ca name=\"module_h3.uncompactCells\"\u003e\u003c/a\u003e\n\n### h3.uncompactCells(compactedSet, res) ⇒ \u003ccode\u003eArray.\u0026lt;H3Index\u0026gt;\u003c/code\u003e\nUncompact a compacted set of hexagons to hexagons of the same resolution\n\n**Returns**: \u003ccode\u003eArray.\u0026lt;H3Index\u0026gt;\u003c/code\u003e - The uncompacted H3 indexes  \n**Throws**:\n\n- \u003ccode\u003eH3Error\u003c/code\u003e If the input is invalid (e.g. invalid resolution)\n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| compactedSet | \u003ccode\u003eArray.\u0026lt;H3IndexInput\u0026gt;\u003c/code\u003e | H3 indexes to uncompact |\n| res | \u003ccode\u003enumber\u003c/code\u003e | The resolution to uncompact to |\n\n\n* * *\n\n\u003ca name=\"module_h3.areNeighborCells\"\u003e\u003c/a\u003e\n\n### h3.areNeighborCells(origin, destination) ⇒ \u003ccode\u003eboolean\u003c/code\u003e\nWhether two H3 indexes are neighbors (share an edge)\n\n**Returns**: \u003ccode\u003eboolean\u003c/code\u003e - Whether the hexagons share an edge  \n**Throws**:\n\n- \u003ccode\u003eH3Error\u003c/code\u003e If the input is invalid\n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| origin | \u003ccode\u003eH3IndexInput\u003c/code\u003e | Origin hexagon index |\n| destination | \u003ccode\u003eH3IndexInput\u003c/code\u003e | Destination hexagon index |\n\n\n* * *\n\n\u003ca name=\"module_h3.cellsToDirectedEdge\"\u003e\u003c/a\u003e\n\n### h3.cellsToDirectedEdge(origin, destination) ⇒ \u003ccode\u003eH3Index\u003c/code\u003e\nGet an H3 index representing a unidirectional edge for a given origin and destination\n\n**Returns**: \u003ccode\u003eH3Index\u003c/code\u003e - H3 index of the edge, or null if no edge is shared  \n**Throws**:\n\n- \u003ccode\u003eH3Error\u003c/code\u003e If the input is invalid\n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| origin | \u003ccode\u003eH3IndexInput\u003c/code\u003e | Origin hexagon index |\n| destination | \u003ccode\u003eH3IndexInput\u003c/code\u003e | Destination hexagon index |\n\n\n* * *\n\n\u003ca name=\"module_h3.getDirectedEdgeOrigin\"\u003e\u003c/a\u003e\n\n### h3.getDirectedEdgeOrigin(edgeIndex) ⇒ \u003ccode\u003eH3Index\u003c/code\u003e\nGet the origin hexagon from an H3 index representing a unidirectional edge\n\n**Returns**: \u003ccode\u003eH3Index\u003c/code\u003e - H3 index of the edge origin  \n**Throws**:\n\n- \u003ccode\u003eH3Error\u003c/code\u003e If the input is invalid\n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| edgeIndex | \u003ccode\u003eH3IndexInput\u003c/code\u003e | H3 index of the edge |\n\n\n* * *\n\n\u003ca name=\"module_h3.getDirectedEdgeDestination\"\u003e\u003c/a\u003e\n\n### h3.getDirectedEdgeDestination(edgeIndex) ⇒ \u003ccode\u003eH3Index\u003c/code\u003e\nGet the destination hexagon from an H3 index representing a unidirectional edge\n\n**Returns**: \u003ccode\u003eH3Index\u003c/code\u003e - H3 index of the edge destination  \n**Throws**:\n\n- \u003ccode\u003eH3Error\u003c/code\u003e If the input is invalid\n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| edgeIndex | \u003ccode\u003eH3IndexInput\u003c/code\u003e | H3 index of the edge |\n\n\n* * *\n\n\u003ca name=\"module_h3.isValidDirectedEdge\"\u003e\u003c/a\u003e\n\n### h3.isValidDirectedEdge(edgeIndex) ⇒ \u003ccode\u003eboolean\u003c/code\u003e\nWhether the input is a valid unidirectional edge\n\n**Returns**: \u003ccode\u003eboolean\u003c/code\u003e - Whether the index is valid  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| edgeIndex | \u003ccode\u003eH3IndexInput\u003c/code\u003e | H3 index of the edge |\n\n\n* * *\n\n\u003ca name=\"module_h3.directedEdgeToCells\"\u003e\u003c/a\u003e\n\n### h3.directedEdgeToCells(edgeIndex) ⇒ \u003ccode\u003eArray.\u0026lt;H3Index\u0026gt;\u003c/code\u003e\nGet the [origin, destination] pair represented by a unidirectional edge\n\n**Returns**: \u003ccode\u003eArray.\u0026lt;H3Index\u0026gt;\u003c/code\u003e - [origin, destination] pair as H3 indexes  \n**Throws**:\n\n- \u003ccode\u003eH3Error\u003c/code\u003e If the input is invalid\n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| edgeIndex | \u003ccode\u003eH3IndexInput\u003c/code\u003e | H3 index of the edge |\n\n\n* * *\n\n\u003ca name=\"module_h3.originToDirectedEdges\"\u003e\u003c/a\u003e\n\n### h3.originToDirectedEdges(h3Index) ⇒ \u003ccode\u003eArray.\u0026lt;H3Index\u0026gt;\u003c/code\u003e\nGet all of the unidirectional edges with the given H3 index as the origin (i.e. an edge to\nevery neighbor)\n\n**Returns**: \u003ccode\u003eArray.\u0026lt;H3Index\u0026gt;\u003c/code\u003e - List of unidirectional edges  \n**Throws**:\n\n- \u003ccode\u003eH3Error\u003c/code\u003e If the input is invalid\n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| h3Index | \u003ccode\u003eH3IndexInput\u003c/code\u003e | H3 index of the origin hexagon |\n\n\n* * *\n\n\u003ca name=\"module_h3.directedEdgeToBoundary\"\u003e\u003c/a\u003e\n\n### h3.directedEdgeToBoundary(edgeIndex, [formatAsGeoJson]) ⇒ \u003ccode\u003eArray.\u0026lt;CoordPair\u0026gt;\u003c/code\u003e\nGet the vertices of a given edge as an array of [lat, lng] points. Note that for edges that\ncross the edge of an icosahedron face, this may return 3 coordinates.\n\n**Returns**: \u003ccode\u003eArray.\u0026lt;CoordPair\u0026gt;\u003c/code\u003e - Array of geo coordinate pairs  \n**Throws**:\n\n- \u003ccode\u003eH3Error\u003c/code\u003e If the input is invalid\n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| edgeIndex | \u003ccode\u003eH3IndexInput\u003c/code\u003e | H3 index of the edge |\n| [formatAsGeoJson] | \u003ccode\u003eboolean\u003c/code\u003e | Whether to provide GeoJSON output: [lng, lat] |\n\n\n* * *\n\n\u003ca name=\"module_h3.gridDistance\"\u003e\u003c/a\u003e\n\n### h3.gridDistance(origin, destination) ⇒ \u003ccode\u003enumber\u003c/code\u003e\nGet the grid distance between two hex indexes. This function may fail\nto find the distance between two indexes if they are very far apart or\non opposite sides of a pentagon.\n\n**Returns**: \u003ccode\u003enumber\u003c/code\u003e - Distance between hexagons  \n**Throws**:\n\n- \u003ccode\u003eH3Error\u003c/code\u003e If input is invalid or the distance could not be calculated\n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| origin | \u003ccode\u003eH3IndexInput\u003c/code\u003e | Origin hexagon index |\n| destination | \u003ccode\u003eH3IndexInput\u003c/code\u003e | Destination hexagon index |\n\n\n* * *\n\n\u003ca name=\"module_h3.gridPathCells\"\u003e\u003c/a\u003e\n\n### h3.gridPathCells(origin, destination) ⇒ \u003ccode\u003eArray.\u0026lt;H3Index\u0026gt;\u003c/code\u003e\nGiven two H3 indexes, return the line of indexes between them (inclusive).\n\nThis function may fail to find the line between two indexes, for\nexample if they are very far apart. It may also fail when finding\ndistances for indexes on opposite sides of a pentagon.\n\nNotes:\n\n - The specific output of this function should not be considered stable\n   across library versions. The only guarantees the library provides are\n   that the line length will be `h3Distance(start, end) + 1` and that\n   every index in the line will be a neighbor of the preceding index.\n - Lines are drawn in grid space, and may not correspond exactly to either\n   Cartesian lines or great arcs.\n\n**Returns**: \u003ccode\u003eArray.\u0026lt;H3Index\u0026gt;\u003c/code\u003e - H3 indexes connecting origin and destination  \n**Throws**:\n\n- \u003ccode\u003eH3Error\u003c/code\u003e If input is invalid or the line cannot be calculated\n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| origin | \u003ccode\u003eH3IndexInput\u003c/code\u003e | Origin hexagon index |\n| destination | \u003ccode\u003eH3IndexInput\u003c/code\u003e | Destination hexagon index |\n\n\n* * *\n\n\u003ca name=\"module_h3.cellToLocalIj\"\u003e\u003c/a\u003e\n\n### h3.cellToLocalIj(origin, destination) ⇒ \u003ccode\u003eCoordIJ\u003c/code\u003e\nProduces IJ coordinates for an H3 index anchored by an origin.\n\n- The coordinate space used by this function may have deleted\nregions or warping due to pentagonal distortion.\n- Coordinates are only comparable if they come from the same\norigin index.\n- Failure may occur if the index is too far away from the origin\nor if the index is on the other side of a pentagon.\n- This function is experimental, and its output is not guaranteed\nto be compatible across different versions of H3.\n\n**Returns**: \u003ccode\u003eCoordIJ\u003c/code\u003e - Coordinates as an `{i, j}` pair  \n**Throws**:\n\n- \u003ccode\u003eH3Error\u003c/code\u003e If the IJ coordinates cannot be calculated\n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| origin | \u003ccode\u003eH3IndexInput\u003c/code\u003e | Origin H3 index |\n| destination | \u003ccode\u003eH3IndexInput\u003c/code\u003e | H3 index for which to find relative coordinates |\n\n\n* * *\n\n\u003ca name=\"module_h3.localIjToCell\"\u003e\u003c/a\u003e\n\n### h3.localIjToCell(origin, coords) ⇒ \u003ccode\u003eH3Index\u003c/code\u003e\nProduces an H3 index for IJ coordinates anchored by an origin.\n\n- The coordinate space used by this function may have deleted\nregions or warping due to pentagonal distortion.\n- Coordinates are only comparable if they come from the same\norigin index.\n- Failure may occur if the index is too far away from the origin\nor if the index is on the other side of a pentagon.\n- This function is experimental, and its output is not guaranteed\nto be compatible across different versions of H3.\n\n**Returns**: \u003ccode\u003eH3Index\u003c/code\u003e - H3 index at the relative coordinates  \n**Throws**:\n\n- \u003ccode\u003eH3Error\u003c/code\u003e If the H3 index cannot be calculated\n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| origin | \u003ccode\u003eH3IndexInput\u003c/code\u003e | Origin H3 index |\n| coords | \u003ccode\u003eCoordIJ\u003c/code\u003e | Coordinates as an `{i, j}` pair |\n\n\n* * *\n\n\u003ca name=\"module_h3.greatCircleDistance\"\u003e\u003c/a\u003e\n\n### h3.greatCircleDistance(latLng1, latLng2, unit) ⇒ \u003ccode\u003enumber\u003c/code\u003e\nGreat circle distance between two geo points. This is not specific to H3,\nbut is implemented in the library and provided here as a convenience.\n\n**Returns**: \u003ccode\u003enumber\u003c/code\u003e - Great circle distance  \n**Throws**:\n\n- \u003ccode\u003eH3Error\u003c/code\u003e If the unit is invalid\n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| latLng1 | \u003ccode\u003eArray.\u0026lt;number\u0026gt;\u003c/code\u003e | Origin coordinate as [lat, lng] |\n| latLng2 | \u003ccode\u003eArray.\u0026lt;number\u0026gt;\u003c/code\u003e | Destination coordinate as [lat, lng] |\n| unit | \u003ccode\u003estring\u003c/code\u003e | Distance unit (either UNITS.m, UNITS.km, or UNITS.rads) |\n\n\n* * *\n\n\u003ca name=\"module_h3.cellArea\"\u003e\u003c/a\u003e\n\n### h3.cellArea(h3Index, unit) ⇒ \u003ccode\u003enumber\u003c/code\u003e\nExact area of a given cell\n\n**Returns**: \u003ccode\u003enumber\u003c/code\u003e - Cell area  \n**Throws**:\n\n- \u003ccode\u003eH3Error\u003c/code\u003e If the input is invalid\n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| h3Index | \u003ccode\u003eH3IndexInput\u003c/code\u003e | H3 index of the hexagon to measure |\n| unit | \u003ccode\u003estring\u003c/code\u003e | Distance unit (either UNITS.m2, UNITS.km2, or UNITS.rads2) |\n\n\n* * *\n\n\u003ca name=\"module_h3.edgeLength\"\u003e\u003c/a\u003e\n\n### h3.edgeLength(edge, unit) ⇒ \u003ccode\u003enumber\u003c/code\u003e\nCalculate length of a given unidirectional edge\n\n**Returns**: \u003ccode\u003enumber\u003c/code\u003e - Cell area  \n**Throws**:\n\n- \u003ccode\u003eH3Error\u003c/code\u003e If the input is invalid\n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| edge | \u003ccode\u003eH3IndexInput\u003c/code\u003e | H3 index of the edge to measure |\n| unit | \u003ccode\u003estring\u003c/code\u003e | Distance unit (either UNITS.m, UNITS.km, or UNITS.rads) |\n\n\n* * *\n\n\u003ca name=\"module_h3.getHexagonAreaAvg\"\u003e\u003c/a\u003e\n\n### h3.getHexagonAreaAvg(res, unit) ⇒ \u003ccode\u003enumber\u003c/code\u003e\nAverage hexagon area at a given resolution\n\n**Returns**: \u003ccode\u003enumber\u003c/code\u003e - Average area  \n**Throws**:\n\n- \u003ccode\u003eH3Error\u003c/code\u003e If the input is invalid\n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| res | \u003ccode\u003enumber\u003c/code\u003e | Hexagon resolution |\n| unit | \u003ccode\u003estring\u003c/code\u003e | Area unit (either UNITS.m2, UNITS.km2, or UNITS.rads2) |\n\n\n* * *\n\n\u003ca name=\"module_h3.getHexagonEdgeLengthAvg\"\u003e\u003c/a\u003e\n\n### h3.getHexagonEdgeLengthAvg(res, unit) ⇒ \u003ccode\u003enumber\u003c/code\u003e\nAverage hexagon edge length at a given resolution\n\n**Returns**: \u003ccode\u003enumber\u003c/code\u003e - Average edge length  \n**Throws**:\n\n- \u003ccode\u003eH3Error\u003c/code\u003e If the input is invalid\n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| res | \u003ccode\u003enumber\u003c/code\u003e | Hexagon resolution |\n| unit | \u003ccode\u003estring\u003c/code\u003e | Distance unit (either UNITS.m, UNITS.km, or UNITS.rads) |\n\n\n* * *\n\n\u003ca name=\"module_h3.cellToVertex\"\u003e\u003c/a\u003e\n\n### h3.cellToVertex(h3Index, vertexNum) ⇒ \u003ccode\u003eH3Index\u003c/code\u003e\nFind the index for a vertex of a cell.\n\n**Returns**: \u003ccode\u003eH3Index\u003c/code\u003e - Vertex index  \n**Throws**:\n\n- \u003ccode\u003eH3Error\u003c/code\u003e If the input is invalid\n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| h3Index | \u003ccode\u003eH3IndexInput\u003c/code\u003e | Cell to find the vertex for |\n| vertexNum | \u003ccode\u003enumber\u003c/code\u003e | Number (index) of the vertex to calculate |\n\n\n* * *\n\n\u003ca name=\"module_h3.cellToVertexes\"\u003e\u003c/a\u003e\n\n### h3.cellToVertexes(h3Index) ⇒ \u003ccode\u003eArray.\u0026lt;H3Index\u0026gt;\u003c/code\u003e\nFind the indexes for all vertexes of a cell.\n\n**Returns**: \u003ccode\u003eArray.\u0026lt;H3Index\u0026gt;\u003c/code\u003e - All vertex indexes of this cell  \n**Throws**:\n\n- \u003ccode\u003eH3Error\u003c/code\u003e If the input is invalid\n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| h3Index | \u003ccode\u003eH3IndexInput\u003c/code\u003e | Cell to find all vertexes for |\n\n\n* * *\n\n\u003ca name=\"module_h3.vertexToLatLng\"\u003e\u003c/a\u003e\n\n### h3.vertexToLatLng(h3Index) ⇒ \u003ccode\u003eCoordPair\u003c/code\u003e\nGet the lat, lng of a given vertex\n\n**Returns**: \u003ccode\u003eCoordPair\u003c/code\u003e - Latitude, longitude coordinates of the vertex  \n**Throws**:\n\n- \u003ccode\u003eH3Error\u003c/code\u003e If the input is invalid\n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| h3Index | \u003ccode\u003eH3IndexInput\u003c/code\u003e | A vertex index |\n\n\n* * *\n\n\u003ca name=\"module_h3.isValidVertex\"\u003e\u003c/a\u003e\n\n### h3.isValidVertex(h3Index) ⇒ \u003ccode\u003eboolean\u003c/code\u003e\nReturns true if the input is a valid vertex index.\n\n**Returns**: \u003ccode\u003eboolean\u003c/code\u003e - True if the index represents a vertex  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| h3Index | \u003ccode\u003eH3IndexInput\u003c/code\u003e | An index to test for being a vertex index |\n\n\n* * *\n\n\u003ca name=\"module_h3.getNumCells\"\u003e\u003c/a\u003e\n\n### h3.getNumCells(res) ⇒ \u003ccode\u003enumber\u003c/code\u003e\nThe total count of hexagons in the world at a given resolution. Note that above\nresolution 8 the exact count cannot be represented in a JavaScript 32-bit number,\nso consumers should use caution when applying further operations to the output.\n\n**Returns**: \u003ccode\u003enumber\u003c/code\u003e - Count  \n**Throws**:\n\n- \u003ccode\u003eH3Error\u003c/code\u003e If the resolution is invalid\n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| res | \u003ccode\u003enumber\u003c/code\u003e | Hexagon resolution |\n\n\n* * *\n\n\u003ca name=\"module_h3.getRes0Cells\"\u003e\u003c/a\u003e\n\n### h3.getRes0Cells() ⇒ \u003ccode\u003eArray.\u0026lt;H3Index\u0026gt;\u003c/code\u003e\nGet all H3 indexes at resolution 0. As every index at every resolution \u003e 0 is\nthe descendant of a res 0 index, this can be used with h3ToChildren to iterate\nover H3 indexes at any resolution.\n\n**Returns**: \u003ccode\u003eArray.\u0026lt;H3Index\u0026gt;\u003c/code\u003e - All H3 indexes at res 0  \n\n* * *\n\n\u003ca name=\"module_h3.getPentagons\"\u003e\u003c/a\u003e\n\n### h3.getPentagons(res) ⇒ \u003ccode\u003eArray.\u0026lt;H3Index\u0026gt;\u003c/code\u003e\nGet the twelve pentagon indexes at a given resolution.\n\n**Returns**: \u003ccode\u003eArray.\u0026lt;H3Index\u0026gt;\u003c/code\u003e - All H3 pentagon indexes at res  \n**Throws**:\n\n- \u003ccode\u003eH3Error\u003c/code\u003e If the resolution is invalid\n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| res | \u003ccode\u003enumber\u003c/code\u003e | Hexagon resolution |\n\n\n* * *\n\n\u003ca name=\"module_h3.degsToRads\"\u003e\u003c/a\u003e\n\n### h3.degsToRads(deg) ⇒ \u003ccode\u003enumber\u003c/code\u003e\nConvert degrees to radians\n\n**Returns**: \u003ccode\u003enumber\u003c/code\u003e - Value in radians  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| deg | \u003ccode\u003enumber\u003c/code\u003e | Value in degrees |\n\n\n* * *\n\n\u003ca name=\"module_h3.radsToDegs\"\u003e\u003c/a\u003e\n\n### h3.radsToDegs(rad) ⇒ \u003ccode\u003enumber\u003c/code\u003e\nConvert radians to degrees\n\n**Returns**: \u003ccode\u003enumber\u003c/code\u003e - Value in degrees  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| rad | \u003ccode\u003enumber\u003c/code\u003e | Value in radians |\n\n\n* * *\n\n\u003ca name=\"module_h3.H3Index\"\u003e\u003c/a\u003e\n\n### h3.H3Index : \u003ccode\u003estring\u003c/code\u003e\n64-bit hexidecimal string representation of an H3 index\n\n\n* * *\n\n\u003ca name=\"module_h3.H3IndexInput\"\u003e\u003c/a\u003e\n\n### h3.H3IndexInput : \u003ccode\u003estring\u003c/code\u003e \\| \u003ccode\u003eArray.\u0026lt;number\u0026gt;\u003c/code\u003e\n64-bit hexidecimal string representation of an H3 index,\nor two 32-bit integers in little endian order in an array.\n\n\n* * *\n\n\u003ca name=\"module_h3.CoordIJ\"\u003e\u003c/a\u003e\n\n### h3.CoordIJ\nCoordinates as an `{i, j}` pair\n\n**Properties**\n\n| Name | Type |\n| --- | --- |\n| i | \u003ccode\u003enumber\u003c/code\u003e | \n| j | \u003ccode\u003enumber\u003c/code\u003e | \n\n\n* * *\n\n\u003ca name=\"module_h3.H3Error\"\u003e\u003c/a\u003e\n\n### h3.H3Error\nCustom JS Error instance with an attached error code. Error codes come from the\ncore H3 library and can be found [in the H3 docs](https://h3geo.org/docs/library/errors#table-of-error-codes).\n\n**Properties**\n\n| Name | Type |\n| --- | --- |\n| message | \u003ccode\u003estring\u003c/code\u003e | \n| code | \u003ccode\u003enumber\u003c/code\u003e | \n\n\n* * *\n\n\u003ca name=\"module_h3.CoordPair\"\u003e\u003c/a\u003e\n\n### h3.CoordPair : \u003ccode\u003eArray.\u0026lt;number\u0026gt;\u003c/code\u003e\nPair of lat,lng coordinates (or lng,lat if GeoJSON output is specified)\n\n\n* * *\n\n\u003ca name=\"module_h3.SplitLong\"\u003e\u003c/a\u003e\n\n### h3.SplitLong : \u003ccode\u003eArray.\u0026lt;number\u0026gt;\u003c/code\u003e\nPair of lower,upper 32-bit ints representing a 64-bit value\n\n\n* * *\n\n\n## Legacy API\n\nH3 v4 renamed the majority of the functions in the library. To help ease migration from H3 v3 to H3 v4, we offer a legacy API wrapper at `h3-js/legacy`, which exports the v4 functions with the v3 names. Users are welcome to use the legacy API wrapper as a transitional support, but are encouraged to upgrade to the H3 v4 API as soon as possible.\n\nNote that the legacy API is _not_ 100% backwards compatible - it's a thin wrapper on top of the v4 functions, so in cases where behavior has changed, the v4 behavior will be used. In particular, many of the v4 functions will throw errors for invalid input, where v3 functions would return null.\n\nInstallation:\n\n```\nnpm install h3-js\n```\n\nUsage:\n\n```\nimport {geoToH3} from 'h3-js/legacy';\n\nconst h3Index = geoToH3(37.3615593, -122.0553238, 7);\n```\n\n## Development\n\nThe `h3-js` library uses `yarn` as the preferred package manager. To install the dev dependencies, just run:\n\n    yarn\n\nTo lint the code:\n\n    yarn lint\n\nTo run the tests:\n\n    yarn test\n\nCode must be formatted with `prettier`; unformatted code will fail the build. To format all files:\n\n    yarn prettier\n\n### Benchmarks\n\nThe `h3-js` library includes a basic benchmark suite using [Benchmark.js](https://benchmarkjs.com/). Because many of the functions may be called over thousands of hexagons in a \"hot loop\", performance is an important concern. Benchmarks are run against the transpiled ES5 code by default.\n\nTo run the benchmarks in Node:\n\n    yarn benchmark-node\n\nTo run the benchmarks in a browser:\n\n    yarn benchmark-browser\n\nSample Node output (Macbook Pro running Node 12):\n\n```\nisValidCell x 3,650,995 ops/sec ±1.67% (87 runs sampled)\nlatLngToCell x 429,982 ops/sec ±1.39% (86 runs sampled)\ncellToLatLng x 1,161,867 ops/sec ±1.11% (84 runs sampled)\ncellToLatLng - integers x 1,555,791 ops/sec ±1.29% (86 runs sampled)\ncellToBoundary x 375,938 ops/sec ±1.25% (87 runs sampled)\ncellToBoundary - integers x 377,181 ops/sec ±1.18% (85 runs sampled)\ngetIcosahedronFaces x 992,946 ops/sec ±1.13% (85 runs sampled)\ngridDisk x 194,400 ops/sec ±1.16% (85 runs sampled)\npolygonToCells_9 x 4,919 ops/sec ±0.79% (87 runs sampled)\npolygonToCells_11 x 368 ops/sec ±0.76% (86 runs sampled)\npolygonToCells_10ring x 76.88 ops/sec ±0.57% (68 runs sampled)\ncellsToMultiPolygon x 760 ops/sec ±1.06% (86 runs sampled)\ncompactCells x 2,466 ops/sec ±0.75% (86 runs sampled)\nuncompactCells x 715 ops/sec ±1.15% (85 runs sampled)\nareNeighborCells x 1,073,086 ops/sec ±1.56% (89 runs sampled)\ncellsToDirectedEdge x 692,172 ops/sec ±1.06% (86 runs sampled)\ngetDirectedEdgeOrigin x 995,390 ops/sec ±1.60% (85 runs sampled)\ngetDirectedEdgeDestination x 930,473 ops/sec ±1.11% (86 runs sampled)\nisValidDirectedEdge x 3,505,407 ops/sec ±1.05% (87 runs sampled)\n```\n\nWhen making code changes that may affect performance, please run benchmarks against `master` and then against your branch to identify any regressions.\n\n### Transpiling the C Source\n\nThe core library is transpiled using [emscripten](http://kripken.github.io/emscripten-site). The easiest way to build from source locally is by using Docker. Make sure Docker is installed, then:\n\n    yarn docker-boot\n    yarn build-emscripten\n\nThe build script uses the `H3_VERSION` file to determine the version of the core library to build. To use a different version of the library (e.g. to test local changes), clone the desired H3 repo to `./h3c` and then run `yarn docker-emscripten`.\n\n## Contributing\n\nPull requests and [Github issues](https://github.com/uber/h3-js/issues) are welcome. Please include tests for new work, and keep the library test coverage at 100%. Please note that the purpose of this module is to expose the API of the [H3 Core library](https://github.com/uber/h3), so we will rarely accept new features that are not part of that API. New proposed feature work is more appropriate in the core C library or in a new JS library that depends on `h3-js`.\n\nBefore we can merge your changes, you must agree to the [Uber Contributor License Agreement](http://cla-assistant.io/uber/h3-js).\n\n## Versioning\n\nThe [H3 core library](https://github.com/uber/h3) adheres to [Semantic Versioning](http://semver.org/). The `h3-js` library has a `major.minor.patch` version scheme. The major and minor version numbers of `h3-js` are the major and minor version of the bound core library, respectively. The patch version is incremented independently of the core library.\n\n## Legal and Licensing\n\nThe `h3-js` library is licensed under the [Apache 2.0 License](https://github.com/uber/h3-js/blob/master/LICENSE).\n\nDGGRID Copyright (c) 2015 Southern Oregon University\n","funding_links":[],"categories":["JavaScript","javascript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuber%2Fh3-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fuber%2Fh3-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuber%2Fh3-js/lists"}