geojson

A Rust library for reading, writing, and serializing the GeoJSON vector GIS format

Library
Cargo
v1.0.0
345stars
MIT OR Apache-2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
42/100Fair
Development Activity12
Maintenance0
Community76
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
78/100Good
Architecture80
Code Quality82
Innovation78
Learning Curve70

geojson is the GeoRust community’s library for working with the GeoJSON format in Rust. It parses GeoJSON documents into strongly typed structures (Feature, FeatureCollection, Geometry) and serializes them back to JSON, built on top of serde and serde_json.

Beyond raw parsing, it offers convenient conversions to and from the geo-types primitives used across the GeoRust ecosystem, streaming feature readers and writers for large datasets, and serde-driven (de)serialization of custom structs directly to and from GeoJSON features.

What You Get

  • Typed representations of GeoJSON Feature, FeatureCollection, and Geometry
  • serde-based (de)serialization to and from JSON
  • Optional conversions to and from geo-types geometry primitives
  • Streaming FeatureReader and FeatureWriter for processing large datasets incrementally
  • Direct serde (de)serialization of custom structs as GeoJSON features

Common Use Cases

  • Parsing GeoJSON files into typed geometries for spatial analysis
  • Streaming large FeatureCollections without loading them fully into memory
  • Serializing computed geometries back out as GeoJSON for maps and APIs

Under The Hood

Architecture - The crate is organized around a set of typed structs in feature.rs, feature_collection.rs, and geometry.rs, with a central GeoJson enum in geojson.rs tying them together. Serialization and deserialization live in ser.rs and de.rs, while feature_reader.rs/feature_writer.rs and feature_iterator.rs implement the streaming API. A conversion/ module bridges to geo-types, and errors.rs centralizes error variants via thiserror.

Tech Stack - Written in Rust (edition 2024) targeting a minimum Rust of 1.34-era APIs. Core dependencies are serde (with derive) and serde_json for the format layer, thiserror for errors, log for diagnostics, and tinyvec for compact position storage; geo-types is an optional default feature. Benchmarks use criterion.

Code Quality - The codebase is modular with one concern per file and a dedicated errors.rs. It ships a tests/ directory with roundtrip tests over JSON fixtures plus multiple criterion benchmarks (parse, serialize, to_geo_types), indicating attention to both correctness and performance. As a long-lived GeoRust project with 36 contributors it follows the ecosystem’s conventions.

API Design - The public API reads naturally: values parse via str::parse / TryFrom, convert to geo-types through From/TryFrom impls, and stream through FeatureReader/FeatureWriter. serde derive support means users can annotate their own structs and (de)serialize GeoJSON directly, minimizing boilerplate. Documentation is thorough on docs.rs with worked examples in the README.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search