Skip to content
Back to skills

Ogr2ogr Recipes

ASecurity

Use when converting, reprojecting, filtering, or loading vector data between formats with GDAL/OGR (ogr2ogr) — shapefile, GeoJSON, GeoPackage, PostGIS, and similar. Makes the agent use correct, safe ogr2ogr invocations instead of guessed flags, and prefer robust formats over fragile ones.

  • 2 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 7, 2026
ai-agentsgosql

Works with

  • cli

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned September 7, 2026

npx -y skills add buildmoonshot/skillpacks --skill ogr2ogr-recipes --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Ogr2ogr Recipes?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Ogr2ogr Recipes
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/buildmoonshot-ogr2ogr-recipes/badge)](https://www.skillsdirectory.com/skills/buildmoonshot-ogr2ogr-recipes)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: ogr2ogr-recipes
description: Use when converting, reprojecting, filtering, or loading vector data between formats with GDAL/OGR (ogr2ogr) — shapefile, GeoJSON, GeoPackage, PostGIS, and similar. Makes the agent use correct, safe ogr2ogr invocations instead of guessed flags, and prefer robust formats over fragile ones.
---

# ogr2ogr Recipes

`ogr2ogr` is the fastest way to move vector data around — and easy to get subtly wrong. Use the known-good patterns.

## Reproject correctly

- `-t_srs EPSG:xxxx` transforms to a target CRS.
- `-s_srs EPSG:yyyy` sets the **source** CRS — needed when the source CRS is undefined or wrong. Setting `-s_srs` does **not** move coordinates; only `-t_srs` transforms them. (This is the define-vs-project distinction; see `crs-discipline`.)

## Pick robust formats

- Prefer **GeoPackage** (`-f GPKG`) over shapefile: no 2 GB limit, no 10-character field-name truncation, no `.dbf` encoding surprises, multiple layers in one file.
- Use `-nlt PROMOTE_TO_MULTI` to avoid "mixed single/multi geometry" failures when a layer has both.

## Load into PostGIS

```
ogr2ogr -f PostgreSQL "PG:host=... dbname=... user=..." input.gpkg \
  -nln schema.table -nlt PROMOTE_TO_MULTI -lco GEOMETRY_NAME=geom -lco FID=id
```

## Filter on the way through

- Attributes: `-where "status = 'active'"`
- Bounding box: `-spat xmin ymin xmax ymax`
- Clip to a layer: `-clipsrc clip.gpkg`

## Safety

- Run `ogrinfo -so <file>` first to confirm layer name, CRS, geometry type, and feature count — and again after, to verify.
- `-makevalid` repairs geometry in transit; use `-skipfailures` only when you understand what's being skipped (and report how many).

## Why this matters

A guessed `ogr2ogr` command often "succeeds" while silently truncating field names, dropping the CRS, mangling encoding, or skipping features. The recipes above make the common conversions correct and verifiable instead of hopeful.

Files in this skill

  • README.md1.4 KB
  • SKILL.md1.9 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.