geopandas
它能做什么
GeoPandas 是一个使用 Python 处理地理地图数据的工具。它可以帮助整理和分析空间信息,比如城市位置或国家边界。
适用场景
- ✓需要分析地图上两点之间的距离时。
- ✓比较不同地区的面积时。
- ✓合并不同地图图层的信息时。
技能链接
https://github.com/K-Dense-AI/scientific-agent-skills/blob/main/skills/geopandas/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“如何使用地图文件计算巴西所有州的面积?”
每周 5 个新技能,1 分钟读完。
工作原理
GeoPandas 使用类似表格的数据结构来存储地图信息。你可以直接对这些数据进行空间运算,比如计算距离或面积。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
GeoPandas
Use GeoPandas for planar vector data represented as pandas-like GeoSeries and
GeoDataFrame objects. This skill targets stable GeoPandas 1.2.0 (released
2026-09-28). The stable website currently carries a development build label;
release-specific behavior below was checked against the v1.2.0 source and wheel.
Reproducible environment
GeoPandas 1.2.0 requires Python 3.11+, NumPy >=2, pandas >=2.2,
Shapely >=2.1, pyproj >=3.7, pyogrio >=0.8, and packaging. The current
pyproj wheel below requires Python 3.12+. This exact Python 3.12 snapshot was
smoke-tested on 2026-10-01:
uv venv --python 3.12
uv pip install \
"geopandas==1.2.0" \
"numpy==2.5.3" \
"pandas==3.0.6" \
"shapely==2.1.2" \
"pyproj==3.8.0" \
"pyogrio==0.13.0" \
"pyarrow==25.0.1" \
"packaging==26.3"
Keep optional plotting and PostGIS packages pinned in the project lock as well. Do not mix binary geospatial packages from incompatible package channels.
Workflow
- Inspect a vetted local layer with
vector_inventory.py; retain source hashes. - Use
crs_reprojection_plan.pyto inspect candidate transformations. It plans only: execute an appropriateto_crs()/pyproj transformation separately. - Audit geometry with
geometry_validity_report.py; compare simulated repair changes before requesting its optional new GeoPackage output. - Run the intended analysis with explicit predicates, CRS units, precision,
and aggregation rules.
spatial_join_audit.pymeasures join cardinality; it does not export joined features or perform a dissolve. - Use
export_plan.pyto inspect the proposed contract, then write and reopen the actual output separately. A successful plan has not written a file. - Review disclosure and generalization before sharing derived geodata/maps,
using
sensitive_coordinates_checklist.pywhen sensitive locations occur.
Examples below use synthetic or placeholder local inputs. File/database examples need the named dataset or service; PostGIS and tile-provider calls were reviewed against upstream contracts but were not exercised against a live service.
Safety and privacy contract
- Treat exact coordinates, addresses, parcel boundaries, trajectories, and small-area joins as sensitive. Default reports to counts, categories, coarse extents, and redacted identifiers. Generalize before publication.
- Never automatically load a URL, cloud URI, GDAL
/vsi*path, archive, or geocode an address. Obtain explicit approval, validate provenance and hashes, then stage an unpacked local file in an isolated workspace. - GDAL/OGR drivers, GEOS, PROJ, pyogrio, Shapely, pyproj, and their wheels are a native-code trust boundary. Prefer official wheels/conda-forge, record native versions, restrict drivers, and process untrusted data in a sandbox.
- Do not open macro-enabled office files or nested archives through permissive GDAL drivers. The bundled CLIs use an extension allowlist and reject archives.
- Read only named database secrets such as
GEOPANDAS_POSTGIS_PASSWORD; use a secret manager or scoped environment variable. Never embed a password in a URL or source, print an engine/URL, or dump the environment. - Every derived artifact needs source hashes/versions, CRS, operation parameters, predicate, join cardinality, precision/repair choices, and row-count checks.
Correctness gates
Apply these gates before trusting a result:
- Identity and provenance — identify the source layer, stable feature key, duplicate IDs, row count, geometry column, parser/driver, and content hash.
- Geometry state — count null, empty, invalid, mixed, Z/M, and collapsed
geometries separately.
Noneis missing; an empty Shapely geometry is real. - CRS semantics — require CRS metadata.
set_crs()assigns metadata;to_crs()transforms coordinates. Never guess a CRS from coordinate ranges. - Units and operation — GeoPandas is planar. Geographic coordinates are angular; do not use them directly for buffer, distance, area, nearest joins, precision grids, or tolerances. Choose a fit-for-purpose local/equal-area CRS or a geodesic method.
- Transform quality — inspect axis order, area of use, datum pipeline, expected accuracy, ballpark status, and missing grids. Keep PROJ network disabled unless the user explicitly approves grid retrieval.
- Topology and precision — validate before and after repair/overlay. Pick a
…
常见问题
什么是地理数据?
它是带有地球位置信息的数据,比如一个地址、一个 GPS 坐标点,或是表示一个国家的多边形。
什么是 CRS?
CRS 是坐标参考系统(Coordinate Reference System)的缩写。它是一套规则,规定经纬度等坐标如何与地球表面对应,从而确保地图准确。
GeoPandas 可以用于所有类型的地图吗?
GeoPandas 最适合矢量数据(点、线、面),也能很好地支持常见的地图格式,但对于更复杂的数据或特定来源的数据,可能需要额外的配置。
详情
作者的原始描述
Guidance and local audit tools for Python workflows that directly use GeoPandas GeoSeries, GeoDataFrame, spatial operations, or vector-data I/O.
热度
- GitHub 星标
- 51k
- 排名
- #3470
- 许可证
- MIT
- 更新时间
- 2026/10/15
评论
- …