Skip to content

Add --ids to osm_planet_extract to cut selected extents - #49

Merged
drewda merged 2 commits into
masterfrom
extract-ids
Oct 1, 2026
Merged

drewda merged 2 commits into
masterfrom
extract-ids

Conversation

@drewda

@drewda drewda commented Oct 1, 2026

Copy link
Copy Markdown
Member

Toward interline-io/tilecutter#51. With OSM Extracts winding down, users need a way to cut a single region themselves. --csv, --geojson and --poly cut every extent in the file, so reproducing one OSM Extracts region from the 149-feature cities.json meant hand-editing the file.

osm_planet_extract --toolchain=osmium --geojson=cities.json --ids=us-ca,berlin_germany --outpath=data/osm_extracts planet-latest.osm.pbf
  • --ids takes comma-separated names and works with any extents file.
  • An unknown name is a usage error (exit 2) that lists the missing names, before any extraction starts. A typo against a planet would otherwise mean an hour of work with no output. tilecutter's fan-out fails the same way.
  • GeoJSON features without an id are keyed by their position, so ids are compared as strings.
  • The README shows how to fetch cities.json from osm-extracts and cut regions from it. I left out a flag that downloads it automatically, so PlanetUtils doesn't depend on that repo staying put.

Testing

  • New tests/test_extract_ids.py covers GeoJSON, CSV, position-keyed features, whitespace, unknown ids and empty --ids.
  • Full suite: 227 passed, 2 skipped. ruff check is clean.
  • Ran it for real with osmium against examples/san-francisco-downtown.osm.pbf and the live cities.json: --ids=us-ca,san-francisco_california wrote both PBFs, and --ids=us-cal exited 2 without extracting anything.

🤖 Generated with Claude Code

--csv, --geojson and --poly cut every extent in the file. --ids takes a
comma-separated list of names and cuts only those, failing on any name
not in the file so a typo does not quietly produce nothing.

This lets users reproduce individual OSM Extracts regions from the
osm-extracts cities.json now that the hosted service is winding down
(interline-io/tilecutter#51).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 1, 2026 04:32

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

--ids= bypasses validation and unexpectedly extracts every extent.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Adds selective extent extraction via comma-separated --ids.

Changes:

  • Filters GeoJSON, CSV, and poly extents by ID.
  • Reports unknown or empty IDs before extraction.
  • Documents usage and adds tests.
File Description
planetutils/​osm_planet_extract.py Implements --ids filtering.
tests/​test_extract_ids.py Tests selection and validation behavior.
README.md Documents selective extraction.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread planetutils/osm_planet_extract.py Outdated
@drewda
drewda merged commit 98e24ff into master Oct 1, 2026
27 checks passed
@drewda
drewda deleted the extract-ids branch October 1, 2026 23:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants