{"id":"geopandas","name":"geopandas","summary":"GeoPandas GeoSeries、GeoDataFrame、空間操作、ベクターデータI/Oを直接使用するPythonワークフロー向けのガイダンスおよびローカル監査ツール。","body":"# GeoPandas\n\nUse GeoPandas for planar vector data represented as pandas-like `GeoSeries` and\n`GeoDataFrame` objects. This skill targets stable **GeoPandas 1.1.4** (released\n2026-06-26), not the unreleased 1.2 documentation.\n\n## Reproducible environment\n\nGeoPandas 1.1.4 requires Python 3.10+; its tagged source requires NumPy >=1.24,\npandas >=2.0, Shapely >=2.0, pyproj >=3.5, pyogrio >=0.7.2, and `packaging`.\nThis exact Python 3.12 snapshot was smoke-tested on 2026-07-23:\n\n```bash\nuv venv --python 3.12\nuv pip install \\\n  \"geopandas==1.1.4\" \\\n  \"numpy==2.5.1\" \\\n  \"pandas==3.0.5\" \\\n  \"shapely==2.1.2\" \\\n  \"pyproj==3.7.2\" \\\n  \"pyogrio==0.13.0\" \\\n  \"pyarrow==25.0.0\" \\\n  \"packaging==26.2\"\n```\n\nKeep optional plotting and PostGIS packages pinned in the project lock as well.\nDo not mix binary geospatial packages from incompatible package channels.\n\n## Safety and privacy contract\n\n- Treat exact coordinates, addresses, parcel boundaries, trajectories, and\n  small-area joins as sensitive. Default reports to counts, categories, coarse\n  extents, and redacted identifiers. Generalize before publication.\n- Never automatically load a URL, cloud URI, GDAL `/vsi*` path, archive, or\n  geocode an address. Obtain explicit approval, validate provenance and hashes,\n  then stage an unpacked local file in an isolated workspace.\n- GDAL/OGR drivers, GEOS, PROJ, pyogrio, Shapely, pyproj, and their wheels are a\n  native-code trust boundary. Prefer official wheels/conda-forge, record native\n  versions, restrict drivers, and process untrusted data in a sandbox.\n- Do not open macro-enabled office files or nested archives through permissive\n  GDAL drivers. The bundled CLIs use an extension allowlist and reject archives.\n- Read only named database secrets such as `GEOPANDAS_POSTGIS_PASSWORD`; use a\n  secret manager or scoped environment variable. Never embed a password in a\n  URL or source, print an engine/URL, or dump the environment.\n- Every derived artifact needs source hashes/versions, CRS, operation parameters,\n  predicate, join cardinality, precision/repair choices, and row-count checks.\n\n## Correctness gates\n\nApply these gates before trusting a result:\n\n1. **Identity and provenance** — identify the source layer, stable feature key,\n   duplicate IDs, row count, geometry column, parser/driver, and content hash.\n2. **Geometry state** — count null, empty, invalid, mixed, Z/M, and collapsed\n   geometries separately. `None` is missing; an empty Shapely geometry is real.\n3. **CRS semantics** — require CRS metadata. `set_crs()` assigns metadata;\n   `to_crs()` transforms coordinates. Never guess a CRS from coordinate ranges.\n4. **Units and operation** — GeoPandas is planar. Geographic coordinates are\n   angular; do not use them directly for buffer, distance, area, nearest joins,\n   precision grids, or tolerances. Choose a fit-for-purpose local/equal-area CRS\n   or a geodesic method.\n5. **Transform quality** — inspect axis order, area of use, datum pipeline,\n   expected accuracy, ballpark status, and missing grids. Keep PROJ network\n   disabled unless the user explicitly approves grid retrieval.\n6. **Topology and precision** — validate before and after repair/overlay. Pick a\n   precision grid from source accuracy and CRS units; arbitrary snapping can\n   collapse features or create bias.\n7. **Cardinality** — state expected one-to-one, one-to-many, or many-to-many\n   behavior before `merge`, `sjoin`, or `sjoin_nearest`; audit unmatched and\n   multiplied rows afterward.\n8. **Output contract** — use a new output path, preserve a stable feature ID,\n   document schema/CRS/encoding, reopen the artifact, and compare counts/types.\n\n## CRS and antimeridian rules\n\nGeoPandas stores CRS as `pyproj.CRS`. Coordinate arrays use traditional GIS\n`(x, y)` order, while authority definitions can advertise latitude-first axes.\nUse `Transformer(..., always_xy=True)` for explicit coordinate-array pipelines,\nand record that choice.\n\n`to_crs()` transforms vertices and assumes each segment is straight in the\nsource CRS; it does not transform geodesic arcs. Geometries crossing ±180° or a\nprojection boundary can be badly wrapped. Detect crossings, split/unwrap and\ndensify in a documented geographic representation, transform parts, then\nvalidate. Do not use Web Mercator as a general measurement CRS.\n\n```python\ncrs = gdf.crs  # a pyproj.CRS when present\nif crs is None or crs.is_geographic:\n    raise ValueError(\"Choose a justified projected CRS before planar measurement\")\n\nunit_names = [axis.unit_name for axis in crs.axis_info]\nareas = gdf.geometry.area  # square CRS units, not automatically square metres\n```\n\nSee [CRS management](references/crs-management.md).\n\n## Core API decisions\n\n### Data structures\n\n- A `GeoDataFrame` can hold multiple geometry columns, each with CRS metadata,\n  but only `active_geometry_name` drives frame-level spatial operations.\n- Binary `GeoSeries` methods are row-wise and align by index by default. Use\n  `align=False` only when positional pairing is explicitly intended and lengths\n  and order were verified.\n- Duplicate column names and duplicate feature IDs are ambiguous; reject or\n  resolve them before joins and exports.\n\nSee [data structures](references/data-structures.md).\n\n### Geometry validity, precision, and union\n\nUse `is_valid` and redacted `is_valid_reason()` categories before\n`make_valid(method=\"linework\"|\"structure\", keep_collapsed=...)`. Repair can\nchange geometry type or dimension; retain the original and compare counts,\narea, types, empties, and collapsed parts.\n\n`set_precision(grid_size, mode=...)` uses **CRS units** and may remove duplicate\nvertices or collapse features. `union_all(method=\"unary\", grid_size=...)` is the\nrobust default. Use `coverage` only after `is_valid_coverage()` proves\nnon-overlap and edge matching; use `disjoint_subset` with Shapely >=2.1 when its\npartitioning assumption is useful.\n\nSee [geometric operations](references/geometric-operations.md).\n\n### Joins, overlay, clip, and dissolve\n\n- `sjoin` predicates are directional: `left.within(right)` is not\n  `left.contains(right)`. `intersects` includes boundary contact; `contains`\n  excludes boundary-only points, while `covers` includes boundary points.\n- `predicate=\"dwithin\"` requires `distance`; scalar or per-left-row distances\n  are in CRS units. `sjoin_nearest` returns all equidistant nearest matches and\n  does **not** implement a `k=` parameter.\n- `overlay(..., make_valid=True)` repairs invalid input but can change types;\n  `keep_geom_type=None` drops other types with a warning. Precision mismatch can\n  create slivers; quantify them rather than silently deleting them.\n- `clip` dissolves the mask. Rectangle clipping is fast but possibly dirty and\n  may omit a line collapsed to a point; validate its output.\n- `dissolve` combines `groupby.agg` with `union_all`; choose explicit attribute\n  aggregations and audit null group keys.\n\nSee [spatial analysis](references/spatial-analysis.md).\n\n### I/O, Arrow, and PostGIS\n\nGeoPandas 1.x defaults to pyogrio. Driver availability and semantics come from\nthe installed GDAL, not GeoPandas alone. Prefer local GeoPackage for general\ninterchange and WKB GeoParquet for columnar interoperability.\n\nGeoParquet defaults to stable schema 1.0.0. Native GeoArrow encodings and bbox\ncovering require schema 1.1.0 and remain less interoperable. A missing GeoParquet\n`crs` key means `OGC:CRS84`; explicit `crs: null` means unknown—do not conflate\nthem. Reopen and validate every export.\n\nUse parameterized SQL and a SQLAlchemy `Engine`/`Connection` for PostGIS.\n`if_exists=\"replace\"` is destructive; default to `\"fail\"` and use a transaction.\n\nSee [data I/O](references/data-io.md).\n\n## Migration checklist\n\nFor code moving from GeoPandas 0.14 or earlier:\n\n- GeoPandas 1.0 supports Shapely >=2 only; PyGEOS, Shapely <2, and the rtree\n  spatial-index backend were removed.\n- pyogrio replaced Fiona as the installed/default I/O engine. Set `engine=`\n  explicitly and test schema, empty, datetime, encoding, and append behavior.\n- Replace `sjoin(op=...)` with `predicate=`, `sindex.query_bulk()` with\n  `sindex.query()`, `unary_union` with `union_all()`, and\n  `GeometryArray.data` with `to_numpy()`/`np.asarray`.\n- Replace `read_file(include_fields=...|ignore_fields=...)` with `columns=`.\n  Use `schema_version=`, not the removed GeoParquet `version=` compatibility.\n- Do not use removed `geopandas.datasets`, internal `geopandas.io.*` entry\n  points, plot `axes`/`colormap`, or set-operation operators.\n- `explode()` now defaults `index_parts=False`; a named Series passed to\n  `set_geometry()` supplies the new active-column name; a named right index can\n  replace `index_right` in `sjoin` output.\n- Do not assign `.crs` to override metadata or rely on deprecated\n  `set_geometry(drop=...)`; use explicit `set_crs()` and rename/drop steps.\n- GeoPandas 1.1 requires Python >=3.10, pandas >=2.0, NumPy >=1.24, and pyproj\n  >=3.5. Version 1.1.2 fixed SQL injection through a PostGIS geometry-column\n  name; the pinned 1.1.4 includes that fix.\n\n### Plotting and exploration\n\nMaps are analytical outputs: label units, classification method, missing data,\nnormalization denominator, and date. `explore()` can expose every attribute in\ntooltips/popups and contact tile/CDN servers; generalize first and use\n`tiles=None`, `tooltip=False`, and `popup=False` for a local draft.\n\nSee [visualization](references/visualization.md).\n\n## Bundled local CLIs\n\nAll helpers are deterministic, reject network/archive paths, bound input bytes\nand feature counts, keep imports lazy so `--help` is dependency-free, and emit\nJSON without coordinates or record identifiers.\n\n| CLI | Purpose |\n|---|---|\n| `scripts/vector_inventory.py` | Redacted local vector/GeoParquet technical inventory |\n| `scripts/crs_reprojection_plan.py` | CRS units, axes, candidate transform and antimeridian plan |\n| `scripts/geometry_validity_report.py` | Dry-run validity audit; optional repair to a new GeoPackage |\n| `scripts/spatial_join_audit.py` | Predicate semantics, duplicate IDs and join cardinality |\n| `scripts/export_plan.py` | Non-executing vector/GeoParquet export contract |\n| `scripts/sensitive_coordinates_checklist.py` | Privacy/generalization release gate |\n\n```bash\npython skills/geopandas/scripts/vector_inventory.py --help\npython skills/geopandas/scripts/crs_reprojection_plan.py \\\n  --source-crs EPSG:4326 --target-crs EPSG:32631\npython skills/geopandas/scripts/geometry_validity_report.py data.gpkg\npython skills/geopandas/scripts/spatial_join_audit.py points.gpkg zones.gpkg \\\n  --predicate within --left-id point_id --right-id zone_id\npython skills/geopandas/scripts/export_plan.py data.gpkg result.parquet \\\n  --format geoparquet --schema-version 1.0.0 \\\n  --stable-id-column feature_id --id-unique-verified\npython skills/geopandas/scripts/sensitive_coordinates_checklist.py \\\n  --public-output --precise-points --contains-addresses\n```\n\n## Reference index\n\n- [Data structures](references/data-structures.md)\n- [CRS management](references/crs-management.md)\n- [Geometric operations](references/geometric-operations.md)\n- [Spatial analysis](references/spatial-analysis.md)\n- [Data I/O](references/data-io.md)\n- [Visualization](references/visualization.md)\n\n## Sources (verified 2026-07-23)\n\n- [GeoPandas 1.1.4 on PyPI](https://pypi.org/project/geopandas/1.1.4/) — released 2026-06-26.\n- [GeoPandas 1.1.4 release](https://github.com/geopandas/geopandas/releases/tag/v1.1.4) — bug-fix release.\n- [GeoPandas 1.1.4 tagged dependencies](https://github.com/geopandas/geopandas/blob/v1.1.4/pyproject.toml).\n- [Stable GeoPandas documentation](https://geopandas.org/en/stable/).\n- [GeoPandas 1.0 migration release](https://github.com/geopandas/geopandas/releases/tag/v1.0.0).","author":"@K-Dense-AI","ownerProfile":null,"authorContacts":null,"sourceUrl":"https://github.com/K-Dense-AI/scientific-agent-skills/tree/main/skills/geopandas","license":"MIT","category":"coding","lang":"en","tokens":2955,"stars":0,"calls30d":1,"claimed":false,"visibility":"public","origin":"crawler","version":"0.1.0","createdAt":"2026-08-22","updatedAt":"2026-08-22","files":[{"path":"references/crs-management.md","size":8882,"sha256":"c86db70e56d27727e8e4e159bfe063c81ccb0b79764d8c60aa7d594c61373ee2"},{"path":"references/data-io.md","size":12197,"sha256":"5da20aa9279fd6349b0301a89646040bf9361b5460feb8e1864849f099643ed0"},{"path":"references/data-structures.md","size":7611,"sha256":"00a6d89c53d860c9e81bc5864e46e804cefb74c7f5a643297c495a7235f3f38c"},{"path":"references/geometric-operations.md","size":9739,"sha256":"e68ad33ec5181fd39630ee9c98229b96098c1fe7f9a8f59807371a6cdeb9a00e"},{"path":"references/spatial-analysis.md","size":9840,"sha256":"16c86d764ff8c738ec1b691bc741f016b155639de5da1e9771dc20e0fb91332a"},{"path":"references/visualization.md","size":8665,"sha256":"e93f6c9e9418fbae3dad78e4b537839c83140c5081aa332f84caf12e442c5368"},{"path":"scripts/_common.py","size":21323,"sha256":"f4ef80f3259a4f1da6d8fa4c7b9cab63673aedf637c81727c1822a70ada3423c"},{"path":"scripts/crs_reprojection_plan.py","size":7420,"sha256":"f4490bac304b735835c8986620e76e64ea142e655e241908565dd17834e5e314"},{"path":"scripts/export_plan.py","size":11098,"sha256":"77aa0bae19d1a60128a7dc2a24d06d4f9288d882d960905b154d46c76ebab3d4"},{"path":"scripts/geometry_validity_report.py","size":7436,"sha256":"d1727489a97f8b5941fecb9e7612da727416f4bc3c91a6bc5a8b86052e62f798"},{"path":"scripts/sensitive_coordinates_checklist.py","size":8980,"sha256":"b53830e89bae6c359d237895d8836df29f11b0220facb97eda444d0d98b89079"},{"path":"scripts/spatial_join_audit.py","size":12848,"sha256":"91911e184de4aeb48371134b77c034497026163172b4fdcc2ae2a038ba287672"},{"path":"scripts/vector_inventory.py","size":4488,"sha256":"5b69d0c0f1e99cb9c7c663e4286f703c797b0d150711e1e4c293f6082767483f"}],"requires":{"mcp":[],"tools":["Read Write Bash Glob Grep"]},"safety":{"flags":[{"code":"net.endpoints","kind":"exfiltration","excerpt":"geopandas.org, geoparquet.org, pyogrio.readthedocs.io, pyproj4.github.io, shapely.readthedocs.io","message":"bundled scripts reach 5 external host(s)","severity":"warn"}],"scannedAt":"2026-08-22","hasScripts":true,"networkEndpoints":["geopandas.org","geoparquet.org","pyogrio.readthedocs.io","pyproj4.github.io","shapely.readthedocs.io"]}}