Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

h3-js

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

h3-js

Pure-Javascript version of the H3 library, a hexagon-based geographic grid system

  • 4.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is h3-js?

The h3-js npm package is a JavaScript library for working with the H3 (Hexagonal Hierarchical Geospatial Indexing System) developed by Uber. It allows for efficient spatial indexing and querying of geographic data using hexagonal grids.

What are h3-js's main functionalities?

Geo to H3

Converts a latitude and longitude to an H3 index at a specified resolution. This is useful for spatial indexing and querying.

const h3 = require('h3-js');
const lat = 37.775938728915946;
const lng = -122.41795063018799;
const resolution = 9;
const h3Index = h3.geoToH3(lat, lng, resolution);
console.log(h3Index);

H3 to Geo

Converts an H3 index back to a latitude and longitude. This is useful for decoding spatial indexes back to geographic coordinates.

const h3 = require('h3-js');
const h3Index = '8928308280fffff';
const [lat, lng] = h3.h3ToGeo(h3Index);
console.log(lat, lng);

Get Hexagon Boundary

Gets the boundary of an H3 hexagon as an array of latitude/longitude pairs. This is useful for visualizing the hexagonal grid.

const h3 = require('h3-js');
const h3Index = '8928308280fffff';
const boundary = h3.h3ToGeoBoundary(h3Index);
console.log(boundary);

K-Ring

Finds all hexagons within a given k distance from a specified H3 index. This is useful for neighborhood queries.

const h3 = require('h3-js');
const h3Index = '8928308280fffff';
const k = 1;
const kRing = h3.kRing(h3Index, k);
console.log(kRing);

Hex Ring

Finds all hexagons in a ring of a given k distance from a specified H3 index. This is useful for ring-based queries.

const h3 = require('h3-js');
const h3Index = '8928308280fffff';
const k = 1;
const hexRing = h3.hexRing(h3Index, k);
console.log(hexRing);

Other packages similar to h3-js

Keywords

FAQs

Package last updated on 20 Jan 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc