h3-js
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseH3 Geospatial Indexing — h3-js v4
H3地理空间索引 — 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 library provides JavaScript bindings for the H3 C library via emscripten.
h3-jsnpm install h3-jsjs
import * as h3 from "h3-js"; // ESM
const h3 = require("h3-js"); // CJSH3是Uber推出的分层六边形地理空间索引系统。它使用六边形在16个分辨率(0-15)下对球体进行分块,每个后续分辨率的精细度约为前一个的7倍。库通过emscripten为H3 C语言库提供JavaScript绑定。
h3-jsnpm install h3-jsjs
import * as h3 from "h3-js"; // ESM
const h3 = require("h3-js"); // CJSWhen to Use H3
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单元中,以关联除位置外无共同键的数据集。
- 流动建模 — 通过有向边模拟单元间的移动。统一的邻接距离简化了权重计算。
- 机器学习 — 使用k环和IJ坐标对六边形网格应用卷积等计算机视觉技术。
- 多分辨率分析 — 将大型单元集压缩为混合分辨率表示,然后可展开为任意分辨率进行对比。
H3 vs Alternatives
H3与其他方案对比
| System | Cell Shape | Hierarchy | Identifiers | Key Tradeoff |
|---|---|---|---|---|
| H3 | Hexagon | Aperture 7, approximate containment | 64-bit int | Equidistant neighbors; approximate subdivision |
| S2 | Square | Aperture 4, exact containment | 64-bit int | Exact subdivision; non-equidistant neighbors |
| Geohash | Rectangle | Exact containment | Variable-length string | Simple encoding; severe area distortion at poles |
| Hexbin | Hexagon | None | Projection-specific | Cheap to compute; no hierarchy, not portable |
| Admin boundaries | Irregular | None | Names/codes | Human-meaningful; incomparable sizes, change over time |
| 系统 | 单元形状 | 层级结构 | 标识符 | 关键权衡点 |
|---|---|---|---|---|
| H3 | 六边形 | 孔径7,近似包含 | 64位整数 | 等距邻接单元;近似细分 |
| S2 | 正方形 | 孔径4,精确包含 | 64位整数 | 精确细分;非等距邻接单元 |
| Geohash | 矩形 | 精确包含 | 可变长度字符串 | 编码简单;极地地区面积失真严重 |
| Hexbin | 六边形 | 无 | 投影相关 | 计算成本低;无层级结构,不具备可移植性 |
| 行政边界 | 不规则形状 | 无 | 名称/代码 | 具有人类可读性;大小不可比,随时间变化 |
Concepts
核心概念
Understand these before using the API — they affect correctness.
在使用API前请先理解这些概念,它们会影响结果的正确性。
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.
- 单元(Cell) — H3网格中的六边形或五边形。在代码中使用“cell”;仅当需要区分时使用“hexagon”/“pentagon”。
- H3Index — 64位整数,用于标识任何H3对象(单元、有向边或顶点)。以15-16位的十六进制字符串表示(例如:)。
"85283473fffffff" - 有向边(Directed edge) — H3Index(模式2),表示从一个单元到相邻单元的遍历。
- 顶点(Vertex) — H3Index,表示单元的拓扑顶点。
- 基础单元(Base cell) — 122个分辨率为0的单元之一(110个六边形,12个五边形)。所有单元都由基础单元衍生而来。
- 网格距离(Grid distance) — 从一个单元到另一个单元,经过相邻单元的最小跳数。
Pentagons
五边形
12 pentagons per resolution, centered on icosahedron vertices (all in ocean — land apps rarely hit them). Most functions handle pentagons transparently. Exceptions:
- can throw near pentagons — use
gridRingas the safe alternative.gridDisk - ,
gridDistance, andgridPathCellsmay fail across pentagonal distortion.cellToLocalIj - Pentagon area is ~50% of hexagon area at the same resolution.
每个分辨率下有12个五边形,位于二十面体的顶点处(全部在海洋中——陆地应用很少会涉及到它们)。大多数函数会透明处理五边形。例外情况:
- 在五边形附近可能会抛出错误 — 使用
gridRing作为安全替代方案。gridDisk - 、
gridDistance和gridPathCells可能会因五边形的变形而失效。cellToLocalIj - 相同分辨率下,五边形的面积约为六边形的50%。
Hierarchical Containment Is Approximate
层级包含是近似的
Child cell centers may fall outside their parent's boundary. Geographic containment is approximate; logical containment is exact. Use / for logical hierarchy. For exact boundaries, combine H3 indexing with point-in-polygon checks.
cellToParentcellToChildrencompactCellsuncompactCells子单元的中心可能位于其父单元的边界之外。地理空间包含是近似的;逻辑包含是精确的。使用/处理逻辑层级。如需精确边界,可将H3索引与点-in-多边形检查结合使用。
cellToParentcellToChildrencompactCellsuncompactCellsClass II vs Class III
Class II与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.
分辨率会交替改变约19.1度的方向。偶数分辨率(0、2、4...)= Class II;奇数分辨率(1、3、5...)= Class III。这对依赖网格对齐的算法很重要。
Coordinate Conventions
坐标约定
- Default coordinate order is lat/lng. Pass as the
true/formatAsGeoJsonparameter for lng/lat (GeoJSON) order.isGeoJson - The coordinate reference system uses WGS84/EPSG:4326 with the authalic sphere radius.
- may return more than 6 vertices for cells that cross icosahedron face boundaries.
cellToBoundary
- 默认坐标顺序为纬度/经度。若要使用经度/纬度(GeoJSON)顺序,需将/
formatAsGeoJson参数设为isGeoJson。true - 坐标参考系统使用WGS84/EPSG:4326,并采用等面积球体半径。
- 可能会返回超过6个顶点,对于那些跨越二十面体面边界的单元。
cellToBoundary
Error Handling
错误处理
Invalid inputs throw errors. Check for details.
.messagejs
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.
无效输入会抛出错误。可通过查看详细信息。
.messagejs
try {
h3.cellToChildrenSize("invalid", 9);
} catch (e) {
console.error(e.message); // "Cell argument was not valid"
}常见原因:无效的单元/边/顶点、不兼容的分辨率、网格距离过远的单元、五边形变形。
Resolution Guide
分辨率指南
Each finer resolution has ~7x more cells. Total cells at resolution r: .
2 + 120 * 7^r| Res | Avg Hex Area | Avg Edge Length | Total Cells | Typical Use Case |
|---|---|---|---|---|
| 0 | 4,357,449 km2 | 1,281 km | 122 | Continental |
| 3 | 12,393 km2 | 69 km | 41,162 | Country / state |
| 5 | 253 km2 | 9.9 km | 2,016,842 | Metro area |
| 7 | 5.16 km2 | 1.4 km | 98,825,162 | Neighborhood |
| 9 | 0.105 km2 | 201 m | 4.8 billion | City block |
| 11 | 0.00215 km2 | 28.7 m | 237 billion | Building |
| 13 | 43.9 m2 | 4.1 m | 11.6 trillion | Room |
| 15 | 0.9 m2 | 0.58 m | 569 trillion | Sub-meter |
每个更精细的分辨率的单元数量约为前一个的7倍。分辨率r下的总单元数为:。
2 + 120 * 7^r| 分辨率 | 平均六边形面积 | 平均边长 | 总单元数 | 典型适用场景 |
|---|---|---|---|---|
| 0 | 4,357,449 km² | 1,281 km | 122 | 大陆级别 |
| 3 | 12,393 km² | 69 km | 41,162 | 国家/州级别 |
| 5 | 253 km² | 9.9 km | 2,016,842 | 都会区级别 |
| 7 | 5.16 km² | 1.4 km | 98,825,162 | 社区级别 |
| 9 | 0.105 km² | 201 m | 48亿 | 城市街区级别 |
| 11 | 0.00215 km² | 28.7 m | 2370亿 | 建筑级别 |
| 13 | 43.9 m² | 4.1 m | 11.6万亿 | 房间级别 |
| 15 | 0.9 m² | 0.58 m | 5690万亿 | 亚米级 |
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.
js
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);通过平均边长将半径(公里)转换为k环步数。
js
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.
js
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;
}统计每个单元内的点数量,用于密度可视化或分析。
js
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.
js
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;
}通过网格距离的线性衰减,将每个点的影响扩散到周围单元。
js
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.
js
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减少大型单元集的存储空间。所有输入单元必须具有相同的分辨率。
js
const cells = h3.polygonToCells(polygon, 9);
const compact = h3.compactCells(cells); // 混合分辨率,单元数量更少
const restored = h3.uncompactCells(compact, 9); // 恢复为统一分辨率9GeoJSON Interop
GeoJSON互操作
Coordinate Order
坐标顺序
h3-js defaults to lat/lng (). GeoJSON requires lng/lat (). Pass for the / parameter to switch. Most common integration bug: forgetting this.
[37.77, -122.41][-122.41, 37.77]trueisGeoJsonformatAsGeoJsonh3-js默认使用纬度/经度()。GeoJSON要求使用经度/纬度()。将/参数设为即可切换顺序。最常见的集成错误:忘记设置此参数。
[37.77, -122.41][-122.41, 37.77]isGeoJsonformatAsGeoJsontrueConvert a single cell to a GeoJSON Feature
将单个单元转换为GeoJSON Feature
cellToBoundaryjs
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
},
};
}cellToBoundaryjs
function cellToFeature(cell, properties = {}) {
const boundary = h3.cellToBoundary(cell, true); // true = GeoJSON [经度, 纬度]顺序
return {
type: "Feature",
properties: { h3index: cell, ...properties },
geometry: {
type: "Polygon",
coordinates: [[...boundary, boundary[0]]], // 闭合环
},
};
}Convert a set of cells to a GeoJSON FeatureCollection
将单元集转换为GeoJSON FeatureCollection
One polygon feature per cell — useful for choropleth styling.
js
function cellsToFeatureCollection(cells, getProperties = () => ({})) {
return {
type: "FeatureCollection",
features: cells.map((cell) => cellToFeature(cell, getProperties(cell))),
};
}每个单元对应一个多边形Feature — 适用于分级统计图样式。
js
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
将单元集转换为合并的GeoJSON轮廓
cellsToMultiPolygonjs
function cellsToOutlineFeature(cells) {
const coordinates = h3.cellsToMultiPolygon(cells, true); // true = GeoJSON order
return {
type: "Feature",
properties: {},
geometry: { type: "MultiPolygon", coordinates },
};
}cellsToMultiPolygonjs
function cellsToOutlineFeature(cells) {
const coordinates = h3.cellsToMultiPolygon(cells, true); // true = GeoJSON顺序
return {
type: "Feature",
properties: {},
geometry: { type: "MultiPolygon", coordinates },
};
}Convert a GeoJSON polygon to H3 cells
将GeoJSON多边形转换为H3单元
Pass so h3-js reads coordinates in lng/lat order.
isGeoJson = truejs
function featureToCells(feature, res) {
const coords = feature.geometry.coordinates;
// coords[0] = outer ring, coords[1..n] = holes
return h3.polygonToCells(coords, res, true);
}传入,使h3-js以经度/纬度顺序读取坐标。
isGeoJson = truejs
function featureToCells(feature, res) {
const coords = feature.geometry.coordinates;
// coords[0] = 外环, coords[1..n] = 内环
return h3.polygonToCells(coords, res, true);
}Control containment mode when filling polygons
填充多边形时控制包含模式
polygonToCellspolygonToCellsExperimentaljs
// 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,
);polygonToCellspolygonToCellsExperimentaljs
// 包含所有与多边形边界有重叠的单元(覆盖范围更广)
h3.polygonToCellsExperimental(
coords,
res,
h3.POLYGON_TO_CELLS_FLAGS.containment_overlapping,
true,
);
// 仅包含完全位于多边形内部的单元(更严格)
h3.polygonToCellsExperimental(
coords,
res,
h3.POLYGON_TO_CELLS_FLAGS.containment_full,
true,
);geojson2h3 companion library
geojson2h3配套库
geojson2h3npm install geojson2h3js
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);geojson2h3npm install geojson2h3js
import geojson2h3 from "geojson2h3";
// GeoJSON Feature → 单元集
const cells = geojson2h3.featureToH3Set(geojsonFeature, res);
// 单元集 → GeoJSON FeatureCollection(每个单元对应一个Feature)
const fc = geojson2h3.h3SetToFeatureCollection(cells, (cell) => ({
value: data[cell],
}));
// 单元集 → 单个合并的GeoJSON Feature(轮廓)
const outline = geojson2h3.h3SetToFeature(cells);API Reference
API参考
Indexing
索引
js
h3.latLngToCell(lat, lng, resolution) // → "85283473fffffff"
h3.cellToLatLng(cell) // → [lat, lng] (center point)
h3.cellToBoundary(cell, formatAsGeoJson?) // → [[lat, lng], ...] (vertices)js
h3.latLngToCell(lat, lng, resolution) // → "85283473fffffff"
h3.cellToLatLng(cell) // → [lat, lng](中心点)
h3.cellToBoundary(cell, formatAsGeoJson?) // → [[lat, lng], ...](顶点)Inspection
检查
js
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, ...]js
h3.getResolution(cell); // → 数字(0-15)
h3.isValidCell(cell); // → 布尔值
h3.isPentagon(cell); // → 布尔值
h3.isResClassIII(cell); // → 布尔值
h3.getBaseCellNumber(cell); // → 数字(0-121)
h3.getIcosahedronFaces(cell); // → [faceNum, ...]Hierarchy
层级
js
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); // → celljs
h3.cellToParent(cell, parentRes); // → 单元
h3.cellToChildren(cell, childRes); // → [cell, ...]
h3.cellToCenterChild(cell, childRes); // → 单元
h3.compactCells(cells); // → 混合分辨率的压缩单元集
h3.uncompactCells(cells, res); // → 统一分辨率的展开单元集
h3.cellToChildPos(child, parentRes); // → 位置索引
h3.childPosToCell(childPos, parent, childRes); // → 单元Traversal
遍历
js
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)js
h3.gridDisk(origin, k); // k步范围内的填充圆盘(在五边形附近安全)
h3.gridDiskDistances(origin, k); // 按距离分组的圆盘 → [[ring0], [ring1], ...]
h3.gridRing(origin, k); // 恰好k步的空心环(在五边形附近可能抛出错误)
h3.gridDistance(a, b); // 网格距离(需相同分辨率;可能因五边形变形而失效)
h3.gridPathCells(start, end); // 单元路径(包含起点和终点;可能因五边形变形而失效)
h3.cellToLocalIj(origin, cell); // → {i, j}(实验性;相对于原点的局部坐标)
h3.localIjToCell(origin, { i, j }); // → 单元(实验性)Regions
区域
js
// 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_bboxjs
// polygon = 坐标环数组;第一个是外边界,其余是内环
h3.polygonToCells(polygon, res, isGeoJson?)
h3.cellsToMultiPolygon(cells, formatAsGeoJson?) // 所有单元需相同分辨率且无重复
h3.polygonToCellsExperimental(polygon, res, flags, isGeoJson?)
// flags: containment_center(默认), containment_full, containment_overlapping, containment_overlapping_bboxDirected Edges
有向边
js
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], ...]js
h3.areNeighborCells(a, b); // → 布尔值
h3.cellsToDirectedEdge(origin, dest); // → 边索引
h3.getDirectedEdgeOrigin(edge); // → 单元
h3.getDirectedEdgeDestination(edge); // → 单元
h3.directedEdgeToCells(edge); // → [origin, dest]
h3.originToDirectedEdges(cell); // → [edge, ...](所有6条或5条边)
h3.directedEdgeToBoundary(edge); // → [[lat, lng], ...]Vertexes
顶点
js
h3.cellToVertex(cell, vertexNum); // → vertex index (0-5 hex, 0-4 pentagon)
h3.cellToVertexes(cell); // → [vertex, ...]
h3.vertexToLatLng(vertex); // → [lat, lng]
h3.isValidVertex(vertex); // → booleanjs
h3.cellToVertex(cell, vertexNum); // → 顶点索引(六边形0-5,五边形0-4)
h3.cellToVertexes(cell); // → [vertex, ...]
h3.vertexToLatLng(vertex); // → [lat, lng]
h3.isValidVertex(vertex); // → 布尔值Metrics & Utilities
指标与工具
js
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.km2h3.UNITS.m2h3.UNITS.rads2h3.UNITS.kmh3.UNITS.mh3.UNITS.radsjs
h3.getHexagonAreaAvg(res, h3.UNITS.km2); // 该分辨率下的平均六边形面积
h3.getHexagonEdgeLengthAvg(res, h3.UNITS.km); // 该分辨率下的平均边长
h3.cellArea(cell, h3.UNITS.km2); // 特定单元的精确面积
h3.edgeLength(edge, h3.UNITS.km); // 特定边的精确长度
h3.getNumCells(res); // 该分辨率下的总单元数
h3.greatCircleDistance(point1, point2, h3.UNITS.km); // 大圆距离([纬度,经度]点)
h3.getRes0Cells(); // 所有122个基础单元
h3.getPentagons(res); // 该分辨率下的12个五边形
h3.degsToRads(degrees);
h3.radsToDegs(radians);单位:, , , , ,
h3.UNITS.km2h3.UNITS.m2h3.UNITS.rads2h3.UNITS.kmh3.UNITS.mh3.UNITS.radsv3 to v4 Migration
v3到v4迁移指南
Function names changed in v4. The grid itself is unchanged — indexes from v3 are valid in v4.
| v3 | v4 |
|---|---|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
See reference.md for the complete function name mapping.
v4中函数名称已更改。网格本身未变 — v3的索引在v4中仍然有效。
| v3 | v4 |
|---|---|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
完整的函数名称映射请参考reference.md。
Full Documentation
完整文档
Complete API reference, algorithm internals, community libraries, and 40+ Observable notebooks in reference.md.
完整的API参考、算法内部原理、社区库以及40多个Observable笔记本,请查看reference.md。