#geo #geospatial #wkt


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

#10 in Geospatial

Download history 2417/week @ 2022-10-19 2079/week @ 2022-10-26 1908/week @ 2022-11-02 2175/week @ 2022-11-09 2348/week @ 2022-11-16 1625/week @ 2022-11-23 2576/week @ 2022-11-30 1933/week @ 2022-12-07 1840/week @ 2022-12-14 1060/week @ 2022-12-21 1081/week @ 2022-12-28 1533/week @ 2023-01-04 2245/week @ 2023-01-11 4105/week @ 2023-01-18 4744/week @ 2023-01-25 5735/week @ 2023-02-01

17,400 downloads per month
Used in 12 crates (11 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!(),


~23K SLoC