Rust read/write support for well-known text (WKT)

24 releases

0.10.3 Jun 22, 2022
0.10.1 May 2, 2022
0.10.0 Feb 25, 2022
0.9.2 Apr 30, 2021
0.0.3 Feb 1, 2015

#22 in Geospatial

Download history 6651/week @ 2023-10-17 5820/week @ 2023-10-24 6303/week @ 2023-10-31 7611/week @ 2023-11-07 6189/week @ 2023-11-14 4973/week @ 2023-11-21 7029/week @ 2023-11-28 4796/week @ 2023-12-05 6038/week @ 2023-12-12 3552/week @ 2023-12-19 1847/week @ 2023-12-26 5617/week @ 2024-01-02 5315/week @ 2024-01-09 6275/week @ 2024-01-16 5694/week @ 2024-01-23 4186/week @ 2024-01-30

22,504 downloads per month
Used in 24 crates (18 directly)




Rust read/write support for well-known text (WKT).

Crate API Documentation


Licensed under either of

at your option.


Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


The wkt crate provides conversions to and from the WKT (Well Known Text) geometry format.

Conversions are available via the TryFromWkt and ToWkt traits, with implementations for geo_types primitives enabled by default.

For advanced usage, see the types module for a list of internally used types.

This crate has optional serde integration for deserializing fields containing WKT. See deserialize for an example.


Read geo_types from a WKT string

// This example requires the geo-types feature (on by default). use wkt::TryFromWkt; use geo_types::Point;

let point: Point = Point::try_from_wkt_str("POINT(10 20)").unwrap(); assert_eq!(point.y(), 20.0);

## Write `geo_types` to a WKT string
// This example requires the geo-types feature (on by default).
use wkt::ToWkt;
use geo_types::Point;

let point: Point<f64> = Point::new(1.0, 2.0);
assert_eq!(point.wkt_string(), "POINT(1 2)");

Read or write your own geometry types

Not using geo-types for your geometries? No problem!

You can use Wkt::from_str to parse a WKT string into this crate's intermediate geometry structure. You can use that directly, or if have your own geometry types that you'd prefer to use, utilize that [Wkt] struct to implement the ToWkt or TryFromWkt traits for your own types.

In doing so, you'll likely want to match on one of the WKT types (Point, Linestring, etc.) stored in its item field

use std::str::FromStr;
use wkt::Wkt;
use wkt::Geometry;

let wktls: Wkt<f64> = Wkt::from_str("LINESTRING(10 20, 20 30)").unwrap();
let ls = match wktls.item {
    Geometry::LineString(line_string) => {
        // you now have access to the `wkt::types::LineString`.
        assert_eq!(line_string.0[0].x, 10.0);
    _ => unreachable!(),


~36K SLoC