postgis

postgis is a skill for Claude Code, Codex from znlgis/opengis-skills. It costs 81 tokens per session (3,392 once invoked), scanned B, original, MIT.

A PostgreSQL extension for storing, indexing, and querying location-based data. PostgreSQL is a relational database, and PostGIS adds shapes, coordinate systems, and spatial functions to it.

In plain words
What is it for?
Use it to store map features, find nearby or intersecting objects, transform coordinates, create spatial indexes, and analyse geometry or geography data with SQL.
Why use it?
It lets applications run location queries inside the database, avoiding the need to load all map data into application code first.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to store map features, find nearby or intersecting objects, transform coordinates, create spatial indexes, and analyse geometry or geography data with SQL.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/znlgis/opengis-skills/postgis
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add znlgis/opengis-skills --skill postgis
Clone the repo
git clone --depth 1 https://github.com/znlgis/opengis-skills

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for postgis

README.md
[![agentmods](https://agentmods.dev/badge/skills/znlgis/opengis-skills/postgis/github.svg)](https://agentmods.dev/skills/znlgis/opengis-skills/postgis)
Your own site
<a href="https://agentmods.dev/skills/znlgis/opengis-skills/postgis"><img src="https://agentmods.dev/badge/skills/znlgis/opengis-skills/postgis/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for postgis

Your own site · 80×15
<a href="https://agentmods.dev/skills/znlgis/opengis-skills/postgis"><img src="https://agentmods.dev/badge/skills/znlgis/opengis-skills/postgis.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 81 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,392 The whole file, excluding the scripts and references it only reads on demand.
Security scan B 1 finding. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector warn 7 Sept 2026
SkillSpector: 3 findings, up to medium

These are SkillSpector’s own severities. On a checked sample its high-severity flags on skills were ~96% false positives — a documented command, a public API, a “never do X” rule — so we show them as a caution to read, not a verdict. Why →

  • medium Privilege Escalation · line 43
    Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
    Fix: Avoid sudo/root unless strictly required. Prefer least-privilege patterns. If elevation is needed, document the justification and scope.
  • medium Privilege Escalation · line 46
    Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
    Fix: Avoid sudo/root unless strictly required. Prefer least-privilege patterns. If elevation is needed, document the justification and scope.
  • medium MCP Rug Pull · line 52
    Docker image references without a specific tag (:latest is implicit) or digest (@sha256:...) can be silently replaced by a malicious image.
    Fix: Pin the image: image:tag or image@sha256:abc123
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00081 $0.03392
Opus 5.5 $0.00032 $0.01357
Sonnet 5.5 $0.00016 $0.00678
Haiku 4.5 $0.00008 $0.00339

Measured yesterday against content hash 01b23023a795, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade B, and why

postgis scanned grade B with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Asks for rootmediumPrivilege escalation

A mod that escalates privileges can change anything on the machine, not only the project.

sudo apt install postgresql-17-postgis-3 postgresql-17-postgis-3-scripts
gis/postgis/SKILL.md · 304 lines

How it starts

The opening of the file, as written. The whole thing — 304 lines — stays where its author put it; the contents beside it link to each section on GitHub.

项目地址: https://github.com/postgis/postgis

官方文档: https://postgis.net/docs/

最新版本: 3.6.4(截至 2026-10,Releases);3.7 系列已到 3.7.0rc3,尚未正式发布

许可证: GPL-2.0+

概述

PostGIS 是基于 PostgreSQL 的开源空间数据库扩展,遵循 OGC Simple Features for SQL 规范。核心能力:

  • 空间数据类型:geometry(平面)、geography(球面)、raster、topology、3DZ/4DZM
  • 空间索引:基于 R-Tree-over-GiST,亿级要素仍保持毫秒级查询
  • 1000+ 空间函数:覆盖度量、关系、构造、聚合、栅格代数
  • 坐标参考系:内置 6000+ EPSG 投影,自动 ST_Transform
  • 数据导入导出:与 GDAL/ogr2ogr/shp2pgsql 无缝集成

版本要求: PostgreSQL 12–18 配合 PostGIS 3.x(最新稳定版 3.6.4;3.7 仍处 RC 阶段,候选版为 3.7.0rc3,截至 2026-10);GEOS ≥ 3.8(部分新算子需 GEOS ≥ 3.14)


环境准备

安装

# Debian/Ubuntu
sudo apt install postgresql-17-postgis-3 postgresql-17-postgis-3-scripts

# CentOS/RHEL
sudo yum install postgis36_17

# macOS
brew install postgis

# Docker(推荐,标签格式 <PG 主版本>-<PostGIS 主版本>)
docker run --name pg -e POSTGRES_PASSWORD=pg -p 5432:5432 -d postgis/postgis:17-3.6

启用扩展

CREATE EXTENSION postgis;
CREATE EXTENSION postgis_topology;     -- 拓扑(可选)
CREATE EXTENSION postgis_raster;       -- 栅格(可选)
CREATE EXTENSION postgis_sfcgal;       -- 3D 高级运算(可选)
SELECT PostGIS_Full_Version();         -- 验证

核心 API:数据类型与函数

类型 说明 适用场景
geometry(Point, 4326) 平面几何,速度快 投影坐标系下的常规分析
geography(Point, 4326) 球面几何,距离按米 全球范围、跨经线计算
raster 栅格 DEM、影像

建表与索引

CREATE TABLE poi (
    id SERIAL PRIMARY KEY,
    name TEXT,
    geom geometry(Point, 4326)
);

CREATE INDEX poi_geom_idx ON poi USING GIST (geom);

INSERT INTO poi(name, geom) VALUES
    ('天安门', ST_GeomFromText('POINT(116.397 39.908)', 4326)),
    ('外滩',   ST_SetSRID(ST_MakePoint(121.490, 31.241), 4326));

ANALYZE poi;

常用空间 SQL

1. 空间关系

-- 范围查询:&& 走 GiST 索引
SELECT id, name FROM poi
WHERE geom && ST_MakeEnvelope(116, 39, 117, 40, 4326)
  AND ST_Within(geom, ST_MakeEnvelope(116, 39, 117, 40, 4326));

-- KNN:<-> 走索引
SELECT id, name, geom <-> ST_MakePoint(116.4, 39.9)::geometry AS d
FROM poi ORDER BY d LIMIT 10;

-- 5 公里缓冲区内
SELECT * FROM poi
WHERE ST_DWithin(geom::geography, ST_MakePoint(116.4, 39.9)::geography, 5000);

Read the full file on GitHub · 304 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday Changed · +50 lines 01b23023a795
  2. 8d ago Changed · -2 lines · +26 tokens per session 2c73f71dc1f5
  3. 13d ago Changed 2f8348742726
  4. 14d ago Changed · +4 lines 77268d46ba0c
  5. 1mo ago Changed f1ae08aa338a
  6. 1mo ago First seen · 252 lines · 55 tokens per session scan B 4d4ef02f5f61

Subscribe to this mod's changes

postgis is a skill published in the GitHub repository znlgis/opengis-skills (75 stars, last pushed 2d ago), licensed MIT. It adds 81 tokens to every session and 3,392 once invoked, about $0.0003 per session on Opus 5.5. A static security scan graded it B with 1 finding (asks for root). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.

Related

Other skills, from other repositories

postgresql-expert

Expert-level PostgreSQL database administration, advanced queries, performance tuning, and production operations. Use when the user mentions database, SQL, or performance, or when the task involves Advanced Data Types, Full-Text Search, Advanced Indexes, or Advanced Queries.

personamanagmentlayer/pcl · 56 tokens

postgresql

A guide for administering PostgreSQL, a database system that stores application data and supports SQL queries. It covers connections, users and permissions, database objects, backups, extensions, and query optimisation.

chaterm/terminal-skills · 9 tokens

PostgreSQL

PostgreSQL 17.x — data types, DDL, DML, queries, indexes, full text search, concurrency, performance, functions.

pledgeandgrow/pledge-skills · 34 tokens

postgres-sql-fundamentals

Postgres fundamentals for when you outgrow SQLite — psql, schema design, constraints, indexes, transactions, EXPLAIN, and connection pooling.

vikasudasi/skill-vault · 38 tokens

pgautopilot

Use this skill for ANY PostgreSQL database work through the PGAutoPilot MCP server. Trigger when user asks to: - Explore, query, or manage a PostgreSQL database - Design schemas, tables, or data models for Postgres - Write, optimize, or debug SQL queries - Check database health, performance, or connectivity - Insert…

cyberreinxy/pgautopilot · 142 tokens

connection-troubleshooting

Use this skill when diagnosing PostgreSQL connection issues through PGAutoPilot. Trigger when user asks to: - "I can't connect to the database" - "Connection refused" - "Connection timed out" - "Database is not reachable" - "How do I fix my database URL?" - "The database won't start" - Connection errors…

cyberreinxy/pgautopilot · 114 tokens