h3-pg
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Install
mkdir -p .claude/skills/h3-pg && curl -L -o skill.zip "https://mcp.directory/api/skills/download/3971" && unzip -o skill.zip -d .claude/skills/h3-pg && rm skill.zipInstalls to .claude/skills/h3-pg
About this skill
h3-pg PostgreSQL Extension
Extension Architecture
Two extensions:
CREATE EXTENSION h3— Core H3 bindings (indexing, traversal, hierarchy, inspection,<->operator). No PostGIS dependency.CREATE EXTENSION h3_postgis— PostGIS integration (geometry/geography casts,@operator, polygon fill, raster helpers). Requirespostgisand optionallypostgis_raster.
Postgres-Specific H3 Features
These exist only in h3-pg, not other H3 language bindings.
Direct casts (h3_postgis):
h3index::geometry→ cell centroid as POINT, SRID 4326h3index::geography→ cell centroid as POINT, SRID 4326
Operators:
a <-> b— grid distance in cells between two h3index values (h3)geom @ resolution— index geometry/geography at resolution (h3_postgis)
Operator classes for h3index: BTREE, HASH, BRIN, SP-GIST (h3)
Boundary helpers (h3_postgis):
h3_cell_to_boundary_geometry(h3index)→ polygon with SRID 4326, splits at antimeridianh3_cell_to_boundary_geography(h3index)→ geography polygon, splits at antimeridian
Polygon fill (h3_postgis):
h3_polygon_to_cells(geometry, resolution)→ SETOF h3indexh3_polygon_to_cells(geography, resolution)→ SETOF h3index
Raster integration (h3_postgis, requires postgis_raster):
h3_raster_summary(raster, resolution, [band])— per-cell stats (count, sum, mean, stddev, min, max)h3_raster_summary_clip(...)— clips raster by cell boundariesh3_raster_summary_centroids(...)— uses cell centroids, avoids pentagon edge casesh3_raster_summary_subpixel(...)— for cells smaller than pixelsh3_raster_class_summary*(...)— discrete class counts per cell
Tile helper (h3_postgis):
h3_get_resolution_from_tile_zoom(z, [max_h3_resolution=15], [min_h3_resolution], [hex_edge_pixels=44], [tile_size=512])— returns optimal H3 resolution for XYZ tile zoom levelz, targeting hexagons approximatelyhex_edge_pixelswide on screen
Common Pattern Fixes
| Pattern | DO NOT | DO |
|---|---|---|
| Get centroid | ST_Centroid(h3_cell_to_boundary_geometry(h3)) | h3::geometry |
| Get boundary with SRID | h3_cell_to_boundary(h3)::geometry | h3_cell_to_boundary_geometry(h3) |
| Distance check (meters) | ST_Distance(a.h3::geography, b.h3::geography) <= N | ST_DWithin(a.h3::geography, b.h3::geography, N) |
| Grid distance (cells) | h3_distance(a, b) | a <-> b |
Antimeridian gotcha: Cells crossing 180° are split into valid polygons. ST_Centroid of a split polygon may fall outside the cell — use h3::geometry for centroids instead.
Critical v3 → v4 Renames
| v3 Name (DO NOT USE) | v4 Replacement |
|---|---|
h3_geo_to_h3 | h3_latlng_to_cell |
h3_to_geo | h3_cell_to_latlng |
h3_to_geo_boundary | h3_cell_to_boundary |
h3_k_ring | h3_grid_disk |
h3_k_ring_distances | h3_grid_disk_distances |
h3_hex_ring | h3_grid_ring_unsafe |
h3_line | h3_grid_path_cells |
h3_distance | h3_grid_distance |
h3_to_parent | h3_cell_to_parent |
h3_to_children | h3_cell_to_children |
h3_compact | h3_compact_cells |
h3_uncompact | h3_uncompact_cells |
h3_polyfill | h3_polygon_to_cells |
h3_indexes_are_neighbors | h3_are_neighbor_cells |
h3_hex_area | h3_get_hexagon_area_avg |
h3_hex_area_km2 / h3_hex_area_m2 | h3_get_hexagon_area_avg(res, unit) |
h3_edge_length_km / h3_edge_length_m | h3_get_hexagon_edge_length_avg(res, unit) |
Unit parameters (v4): Area and length functions now take a unit text parameter:
h3_get_hexagon_area_avg(resolution, [unit = 'km^2'])— use'km^2'or'm^2'h3_get_hexagon_edge_length_avg(resolution, [unit = 'km'])— use'km'or'm'h3_cell_area(cell, [unit = 'km^2'])— exact area for specific cellh3_edge_length(edge, [unit = 'km'])— exact length for specific edge
Spelling change (v4.2.3+): Prefer h3_latlng_to_cell over h3_lat_lng_to_cell (underscore version deprecated). Same for h3_cell_to_latlng, h3_vertex_to_latlng.
Documentation
- API reference: https://github.com/postgis/h3-pg/blob/main/docs/api.md
- v3→v4 migration: https://h3geo.org/docs/library/migration-3.x/functions
More by postgis
View all skills by postgis →You might also like
flutter-development
aj-geddes
Build beautiful cross-platform mobile apps with Flutter and Dart. Covers widgets, state management with Provider/BLoC, navigation, API integration, and material design.
ui-ux-pro-max
nextlevelbuilder
"UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient."
drawio-diagrams-enhanced
jgtolentino
Create professional draw.io (diagrams.net) diagrams in XML format (.drawio files) with integrated PMP/PMBOK methodologies, extensive visual asset libraries, and industry-standard professional templates. Use this skill when users ask to create flowcharts, swimlane diagrams, cross-functional flowcharts, org charts, network diagrams, UML diagrams, BPMN, project management diagrams (WBS, Gantt, PERT, RACI), risk matrices, stakeholder maps, or any other visual diagram in draw.io format. This skill includes access to custom shape libraries for icons, clipart, and professional symbols.
godot
bfollington
This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.
nano-banana-pro
garg-aayush
Generate and edit images using Google's Nano Banana Pro (Gemini 3 Pro Image) API. Use when the user asks to generate, create, edit, modify, change, alter, or update images. Also use when user references an existing image file and asks to modify it in any way (e.g., "modify this image", "change the background", "replace X with Y"). Supports both text-to-image generation and image-to-image editing with configurable resolution (1K default, 2K, or 4K for high resolution). DO NOT read the image file first - use this skill directly with the --input-image parameter.
pdf-to-markdown
aliceisjustplaying
Convert entire PDF documents to clean, structured Markdown for full context loading. Use this skill when the user wants to extract ALL text from a PDF into context (not grep/search), when discussing or analyzing PDF content in full, when the user mentions "load the whole PDF", "bring the PDF into context", "read the entire PDF", or when partial extraction/grepping would miss important context. This is the preferred method for PDF text extraction over page-by-page or grep approaches.
Related MCP Servers
Browse all serversToolFront is a knowledge database software and db management system offering unified access to databases with advanced t
Convert lat long or GPS data easily with GIS Operations. Perform coordinate transformations, MGRS, and military grid con
AI Memory is a production-ready vector database server that manages and retrieves contextual knowledge with advanced sem
Aiven MCP Server: access Aiven managed services — managed PostgreSQL, managed Kafka, ClickHouse and managed OpenSearch s
Learn how to use Python to read a file and manipulate local files safely through the Filesystem API.
Extend your developer tools with GitHub MCP Server for advanced automation, supporting GitHub Student and student packag
Stay ahead of the MCP ecosystem
Get weekly updates on new skills and servers.