Token导航 LogoToken导航TokenDH.com
研究检索需要联网github未标认证来源可访问许可证需确认审计通过

h3-jsH3 JS 搜索

Agent Skill

h3-js 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

261

周安装

11

GitHub Stars

1

下载量

92
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:h3-js(H3 JS 搜索)
来源仓库:https://github.com/frontboat/h3-js
仓库路径:skills/h3-js
安装命令:
npx skills add https://github.com/frontboat/h3-js --skill h3-js
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/frontboat/h3-js --skill h3-js

简介

h3-js 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中快速定位候选结果。

  • 适用于需要根据关键词或任务场景从来源线索中获取信息的场景。
  • 通过 npx skills add 命令安装,需结合原始 README 核验具体用法。
  • 安装前建议确认权限范围、维护状态及是否触发联网或文件读写操作。
  • h3-js 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

H3 Geospatial Indexing — h3-js v4

H3 is Uber's hierarchical hexagonal geospatial indexing system. It tiles the sphere with hexagons at 16 resolutions (0-15), each ~7x finer than the last. The h3-js library provides JavaScript bindings for the H3 C library via emscripten.

npm install h3-js
import * as h3 from "h3-js"; // ESM
const h3 = require("h3-js"); // CJS

When to Use H3

  • Aggregation — Bucket points into uniform cells with equidistant neighbors for heatmaps and density analysis.
  • Joining disparate datasets — Index points, lines, and polygons into H3 cells to join datasets that share no common key except location.
  • Flow modeling — Model movement between cells via directed edges. Uniform neighbor distances simplify weighting.
  • Machine learning — Apply convolution and other CV techniques to the hex grid using k-rings and IJ coordinates.
  • Multi-resolution analysis — Compact large cell sets into mixed-resolution representations, then uncompact for comparison at any resolution.

H3 vs Alternatives

SystemCell ShapeHierarchyIdentifiersKey Tradeoff
H3HexagonAperture 7, approximate containment64-bit intEquidistant neighbors; approximate subdivision
S2SquareAperture 4, exact containment64-bit intExact subdivision; non-equidistant neighbors
GeohashRectangleExact containmentVariable-length stringSimple encoding; severe area distortion at poles
HexbinHexagonNoneProjection-specificCheap to compute; no hierarchy, not portable
Admin boundariesIrregularNoneNames/codesHuman-meaningful; incomparable sizes, change over time

Concepts

Understand these before using the API — they affect correctness.

Terminology

  • Cell — A hexagon or pentagon in the H3 grid. Use "cell" in code; "hexagon"/"pentagon" only when the distinction matters.
  • H3Index — 64-bit integer identifying any H3 object (cell, directed edge, or vertex). Represented as a 15-16 char hex string (e.g., "85283473fffffff").
  • Directed edge — H3Index (mode 2) representing traversal from one cell to an adjacent cell.
  • Vertex — H3Index representing a topological vertex of a cell.
  • Base cell — One of 122 resolution-0 cells (110 hexagons, 12 pentagons). Every cell descends from one.
  • Grid distance — Minimum number of hops across adjacent cells from one cell to another.

Pentagons

12 pentagons per resolution, centered on icosahedron vertices (all in ocean — land apps rarely hit them). Most functions handle pentagons transparently. Exceptions:

  • gridRing can throw near pentagons — use gridDisk as the safe alternative.
  • gridDistance, gridPathCells, and cellToLocalIj may fail across pentagonal distortion.
  • Pentagon area is ~50% of hexagon area at the same resolution.

Hierarchical Containment Is Approximate

Child cell centers may fall outside their parent's boundary. Geographic containment is approximate; logical containment is exact. Use cellToParent/cellToChildren for logical hierarchy. For exact boundaries, combine H3 indexing with point-in-polygon checks.

compactCells / uncompactCells use logical containment and are exact.

Class II vs Class III

Resolutions alternate orientation by ~19.1 degrees. Even (0, 2, 4,...) = Class II; odd (1, 3, 5,...) = Class III. Matters for algorithms depending on grid alignment.

Coordinate Conventions

  • Default coordinate order is lat/lng. Pass true as the formatAsGeoJson / isGeoJson parameter for lng/lat (GeoJSON) order.
  • The coordinate reference system uses WGS84/EPSG:4326 with the authalic sphere radius.
  • cellToBoundary may return more than 6 vertices for cells that cross icosahedron face boundaries.

Error Handling

Invalid inputs throw errors. Check .message for details.

try {
  h3.cellToChildrenSize("invalid", 9);
} catch (e) {
  console.error(e.message); // "Cell argument was not valid"
}

Common causes: invalid cell/edge/vertex, incompatible resolutions, cells too far apart for grid distance, pentagon distortion.

Resolution Guide

Each finer resolution has ~7x more cells. Total cells at resolution r: 2 + 120 * 7^r.

ResAvg Hex AreaAvg Edge LengthTotal CellsTypical Use Case
04,357,449 km21,281 km122Continental
312,393 km269 km41,162Country / state
5253 km29.9 km2,016,842Metro area
75.16 km21.4 km98,825,162Neighborhood
90.105 km2201 m4.8 billionCity block
110.00215 km228.7 m237 billionBuilding
1343.9 m24.1 m11.6 trillionRoom
150.9 m20.58 m569 trillionSub-meter

Common Patterns

Find all cells within a radius of a point

Convert a radius (km) to a k-ring step count via average edge length.

const origin = h3.latLngToCell(lat, lng, 8);
const radiusKm = 4;
const edgeKm = h3.getHexagonEdgeLengthAvg(8, h3.UNITS.km);
const k = Math.floor(radiusKm / (edgeKm * 2));
const nearby = h3.gridDisk(origin, k);

Aggregate points into hex bins (heatmap)

Count points per cell for density visualization or analysis.

function aggregatePoints(points, res) {
  const counts = {};
  for (const { lat, lng } of points) {
    const cell = h3.latLngToCell(lat, lng, res);
    counts[cell] = (counts[cell] || 0) + 1;
  }
  return counts;
}

Weight points with distance falloff

Spread each point's influence across surrounding cells with linear decay by grid distance.

function weightWithFalloff(points, res, kRadius) {
  const weights = {};
  const step = 1 / (kRadius + 1);
  for (const { lat, lng } of points) {
    const origin = h3.latLngToCell(lat, lng, res);
    const rings = h3.gridDiskDistances(origin, kRadius);
    rings.forEach((ring, dist) => {
      for (const cell of ring) {
        weights[cell] = (weights[cell] || 0) + 1 - dist * step;
      }
    });
  }
  return weights;
}

Compact and uncompact cell sets

Reduce storage for large cell sets. All input cells must share the same resolution.

const cells = h3.polygonToCells(polygon, 9);
const compact = h3.compactCells(cells); // mixed-resolution, fewer cells
const restored = h3.uncompactCells(compact, 9); // back to uniform res 9

GeoJSON Interop

Coordinate Order

h3-js defaults to lat/lng ([37.77, -122.41]). GeoJSON requires lng/lat ([-122.41, 37.77]). Pass true for the isGeoJson/formatAsGeoJson parameter to switch. Most common integration bug: forgetting this.

Convert a single cell to a GeoJSON Feature

cellToBoundary returns coordinate arrays, not GeoJSON objects. Wrap manually.

function cellToFeature(cell, properties = {}) {
  const boundary = h3.cellToBoundary(cell, true); // true = GeoJSON [lng, lat] order
  return {
    type: "Feature",
    properties: { h3index: cell, ...properties },
    geometry: {
      type: "Polygon",
      coordinates: [[...boundary, boundary[0]]], // close the ring
    },
  };
}

Convert a set of cells to a GeoJSON FeatureCollection

One polygon feature per cell — useful for choropleth styling.

function cellsToFeatureCollection(cells, getProperties = () => ({})) {
  return {
    type: "FeatureCollection",
    features: cells.map((cell) => cellToFeature(cell, getProperties(cell))),
  };
}

Convert a set of cells to a merged GeoJSON outline

cellsToMultiPolygon merges adjacent cells into polygon outlines. All cells must share the same resolution with no duplicates — undefined behavior otherwise.

function cellsToOutlineFeature(cells) {
  const coordinates = h3.cellsToMultiPolygon(cells, true); // true = GeoJSON order
  return {
    type: "Feature",
    properties: {},
    geometry: { type: "MultiPolygon", coordinates },
  };
}

Convert a GeoJSON polygon to H3 cells

Pass isGeoJson = true so h3-js reads coordinates in lng/lat order.

function featureToCells(feature, res) {
  const coords = feature.geometry.coordinates;
  // coords[0] = outer ring, coords[1..n] = holes
  return h3.polygonToCells(coords, res, true);
}

Control containment mode when filling polygons

polygonToCells uses center containment by default — includes a cell only if its center is inside the polygon. Use polygonToCellsExperimental for other modes.

// Include cells that overlap the polygon boundary at all (fuller coverage)
h3.polygonToCellsExperimental(
  coords,
  res,
  h3.POLYGON_TO_CELLS_FLAGS.containment_overlapping,
  true,
);

// Include only cells fully contained within the polygon (stricter)
h3.polygonToCellsExperimental(
  coords,
  res,
  h3.POLYGON_TO_CELLS_FLAGS.containment_full,
  true,
);

geojson2h3 companion library

geojson2h3 provides higher-level conversion helpers:

npm install geojson2h3
import geojson2h3 from "geojson2h3";

// GeoJSON Feature → cell set
const cells = geojson2h3.featureToH3Set(geojsonFeature, res);

// Cell set → GeoJSON FeatureCollection (one Feature per cell)
const fc = geojson2h3.h3SetToFeatureCollection(cells, (cell) => ({
  value: data[cell],
}));

// Cell set → single merged GeoJSON Feature (outline)
const outline = geojson2h3.h3SetToFeature(cells);

API Reference

Indexing

h3.latLngToCell(lat, lng, resolution)    // → "85283473fffffff"
h3.cellToLatLng(cell)                     // → [lat, lng] (center point)
h3.cellToBoundary(cell, formatAsGeoJson?) // → [[lat, lng], ...] (vertices)

Inspection

h3.getResolution(cell); // → number (0-15)
h3.isValidCell(cell); // → boolean
h3.isPentagon(cell); // → boolean
h3.isResClassIII(cell); // → boolean
h3.getBaseCellNumber(cell); // → number (0-121)
h3.getIcosahedronFaces(cell); // → [faceNum, ...]

Hierarchy

h3.cellToParent(cell, parentRes); // → cell
h3.cellToChildren(cell, childRes); // → [cell, ...]
h3.cellToCenterChild(cell, childRes); // → cell
h3.compactCells(cells); // → mixed-resolution compact set
h3.uncompactCells(cells, res); // → uniform-resolution expanded set
h3.cellToChildPos(child, parentRes); // → position index
h3.childPosToCell(childPos, parent, childRes); // → cell

Traversal

h3.gridDisk(origin, k); // filled disk within k steps (safe near pentagons)
h3.gridDiskDistances(origin, k); // disk grouped by distance → [[ring0], [ring1], ...]
h3.gridRing(origin, k); // hollow ring at exactly k steps (may throw near pentagons)
h3.gridDistance(a, b); // grid distance (same resolution; may fail across pentagons)
h3.gridPathCells(start, end); // path of cells (inclusive; may fail across pentagons)
h3.cellToLocalIj(origin, cell); // → {i, j} (experimental; local to origin)
h3.localIjToCell(origin, { i, j }); // → cell (experimental)

Regions

// polygon = array of coordinate rings; first is outer boundary, rest are holes
h3.polygonToCells(polygon, res, isGeoJson?)
h3.cellsToMultiPolygon(cells, formatAsGeoJson?)  // all cells same res, no duplicates
h3.polygonToCellsExperimental(polygon, res, flags, isGeoJson?)
// flags: containment_center (default), containment_full, containment_overlapping, containment_overlapping_bbox

Directed Edges

h3.areNeighborCells(a, b); // → boolean
h3.cellsToDirectedEdge(origin, dest); // → edge index
h3.getDirectedEdgeOrigin(edge); // → cell
h3.getDirectedEdgeDestination(edge); // → cell
h3.directedEdgeToCells(edge); // → [origin, dest]
h3.originToDirectedEdges(cell); // → [edge, ...] (all 6 or 5 edges)
h3.directedEdgeToBoundary(edge); // → [[lat, lng], ...]

Vertexes

h3.cellToVertex(cell, vertexNum); // → vertex index (0-5 hex, 0-4 pentagon)
h3.cellToVertexes(cell); // → [vertex, ...]
h3.vertexToLatLng(vertex); // → [lat, lng]
h3.isValidVertex(vertex); // → boolean

Metrics & Utilities

h3.getHexagonAreaAvg(res, h3.UNITS.km2); // average hex area at resolution
h3.getHexagonEdgeLengthAvg(res, h3.UNITS.km); // average edge length at resolution
h3.cellArea(cell, h3.UNITS.km2); // exact area of a specific cell
h3.edgeLength(edge, h3.UNITS.km); // exact length of a specific edge
h3.getNumCells(res); // total cell count at resolution
h3.greatCircleDistance(point1, point2, h3.UNITS.km); // haversine distance ([lat,lng] points)
h3.getRes0Cells(); // all 122 base cells
h3.getPentagons(res); // 12 pentagons at resolution
h3.degsToRads(degrees);
h3.radsToDegs(radians);

Units: h3.UNITS.km2, h3.UNITS.m2, h3.UNITS.rads2, h3.UNITS.km, h3.UNITS.m, h3.UNITS.rads

v3 to v4 Migration

Function names changed in v4. The grid itself is unchanged — indexes from v3 are valid in v4.

v3v4
geoToH3latLngToCell
h3ToGeocellToLatLng
h3ToGeoBoundarycellToBoundary
kRinggridDisk
hexRinggridRing
h3DistancegridDistance
h3ToParentcellToParent
h3ToChildrencellToChildren
polyfillpolygonToCells
h3SetToMultiPolygoncellsToMultiPolygon
compactcompactCells
uncompactuncompactCells
h3IndexesAreNeighborsareNeighborCells

See reference.md for the complete function name mapping.

Full Documentation

Complete API reference, algorithm internals, community libraries, and 40+ Observable notebooks in reference.md.

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

34.21%
按下载量换算31

Claude

29.79%
按下载量换算27

Cursor

20.51%
按下载量换算19

Gemini CLI

9.96%
按下载量换算9

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills