---
name: geojson
displayName: GeoJSON Reader & Converter
description: Read, inspect, and convert .geojson files to CSV or JSON. Use when
  opening a GeoJSON file, extracting features, or exporting geometry and
  properties to another format.
tags:
  - geospatial
  - geojson
  - converter
  - reader
  - gis
capabilities:
  - ReadGeojson
  - ConvertToCsv
  - ConvertToJson
  - ExtractFeatures
  - SummarizeProperties
representativeQueries:
  - Read a .geojson file and show me its contents
  - Convert GeoJSON to CSV
  - Extract all features from a GeoJSON file
  - Summarize the properties in a GeoJSON FeatureCollection
  - Export GeoJSON geometry and attributes to JSON
version: 0.1.0
tier: curated
---

# GeoJSON Reader & Converter

Read, inspect, and convert `.geojson` files using only the Python standard library. Handles FeatureCollections, bare Features, and bare Geometries. Converts to CSV (properties + serialized geometry) or pretty-printed JSON.

## When to use

- You have a `.geojson` (or `.json` with GeoJSON content) file and need to inspect its features.
- You want to export GeoJSON properties and geometry into CSV for spreadsheet or database use.
- You need a summary of property keys, feature count, or geometry types present in the file.

## Steps

1. **Detect format.** Confirm the file has a `.geojson` (or `.json`) extension and contains valid JSON with a `type` field at root.
2. **Route by task.**
   - To read/inspect: parse the file, identify the root type (FeatureCollection, Feature, or Geometry), and print a human-readable summary plus first N features.
   - To convert to CSV: collect all property keys across all features, write one row per feature with properties flattened and geometry serialized to a JSON string.
   - To convert to JSON: pretty-print the parsed structure (or a subset) as formatted JSON.
3. **Run the script.** Use `scripts/geojson_convert.py` with the file path argument and optional `--format` flag.

## Operations

| Capability | CRUD | Resource | Tool |
|---|---|---|---|
| ReadGeojson | READ | .geojson file | scripts/geojson_convert.py |
| ExtractFeatures | READ | features array | scripts/geojson_convert.py |
| SummarizeProperties | READ | feature properties | scripts/geojson_convert.py |
| ConvertToCsv | READ + local CREATE | CSV output | scripts/geojson_convert.py |
| ConvertToJson | READ + local CREATE | JSON output | scripts/geojson_convert.py |

## Output

- **Summary mode (default):** feature count, geometry types present, property keys, and the first 5 features as formatted JSON.
- **CSV mode (`--format csv`):** one line per feature; columns are all discovered property keys plus a `geometry` column (serialized JSON). Printed to stdout.
- **JSON mode (`--format json`):** the full parsed GeoJSON re-serialized as indented JSON, printed to stdout.

## Notes

- Coordinates follow RFC 7946 order: `[longitude, latitude]` — not `[lat, lon]`.
- Property values may be `null`; the CSV converter renders them as empty strings.
- Nested property objects are written as JSON strings in the CSV (not flattened).
- Files larger than a few hundred MB will load slowly; no streaming is implemented in this version.
- The script exits with a non-zero code and a descriptive error message on malformed JSON or missing file.
- A `GeometryCollection` at the root is treated as a bare geometry and wrapped in a synthetic Feature with empty properties; this matches the bare-geometry path for all other non-Feature, non-FeatureCollection root types.

<!-- runner-fallback -->
## Remote runner (MCP)
Can't run this locally (no setup, missing dependency)? The StealthStack runner exposes the **same code** as server-side MCP tools — no local install needed: `geojson_summary`, `geojson_to_csv`, `geojson_to_json`. Call the `application/mcp` catalog twin of this skill (its `runnerTwin`).
