wkt

Read and write Well-Known Text (WKT) geospatial geometries in Rust

Library
Cargo
v0.14.0
56stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
31/100Needs Attention
Development Activity4
Maintenance0
Community48
Maturity60
Momentum12

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
80/100Excellent
Architecture80
Code Quality82
Innovation72
Learning Curve84

wkt is a Rust library from the GeoRust ecosystem that provides read and write support for Well-Known Text (WKT), the standard textual encoding for geospatial geometries such as points, lines, polygons, and their multi- and collection variants.

It parses WKT strings into strongly-typed geometry values and serializes geometries back to WKT, with optional integration into the geo-types and geo-traits ecosystem and optional Serde support, making it a small, dependency-light building block for geospatial applications.

What You Get

  • A parser that reads WKT strings into typed geometry values
  • Serialization of geometries back to valid WKT text
  • Optional conversions to and from geo-types and geo-traits
  • A wkt! macro for embedding geometry literals directly in Rust code
  • Optional Serde support and a lightweight, dependency-conscious design

Common Use Cases

  • Parsing WKT geometry strings from databases, files, or APIs into typed values
  • Exporting in-memory geometries to WKT for storage or interchange
  • Bridging WKT data into the GeoRust geo-types ecosystem for further processing
  • Embedding geometry literals in tests or code via the wkt! macro

Under The Hood

Architecture — Reading flows through tokenizer.rs (lexing WKT text) into from_wkt.rs and infer_type.rs, producing the typed geometries defined under src/types/; geo_types_from_wkt.rs and geo_types_to_wkt.rs plus conversion.rs bridge to the GeoRust geo-types model, while to_wkt/ handles serialization back to text. wkt_macro.rs implements the wkt! literal macro and error.rs centralizes parse errors via thiserror.

Tech Stack — Rust (edition 2021) with a deliberately small dependency set: geo-traits, num-traits, thiserror, and log, plus optional geo-types (default) and serde. Criterion benchmarks under benches/ cover parse and write paths.

Code Quality — The crate is cleanly modularized by direction (parse vs. write) and by target type, uses typed errors, and ships parse/write benchmarks and a change log. Recent maintenance cadence is low, but the code is mature and widely used (8M+ downloads) with a stable API.

API Design — The API is straightforward: parse via FromStr/from_wkt into typed geometries, write via display/to_wkt, and construct literals with the wkt! macro. Feature flags keep the default surface lean while enabling geo-types and serde when needed, giving a gentle learning curve.

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