| Crates.io | turf-rs |
| lib.rs | turf-rs |
| version | 0.1.2 |
| created_at | 2025-08-25 16:06:53.569439+00 |
| updated_at | 2025-08-30 03:36:10.406415+00 |
| description | A Rust library for advanced geospatial analysis based on Turf, providing powerful tools for manipulating and optimizing geometric data |
| homepage | |
| repository | https://gitlab.com/public-sources1/rust/turf-rs |
| max_upload_size | |
| id | 1809749 |
| size | 91,672 |
A Rust library for advanced geospatial analysis, providing powerful tools for manipulating and optimizing geometric data.
On Debian-based systems, you need to install the libgeos-dev package:
sudo apt-get update && sudo apt-get install -y libgeos-dev
**For others systems like mac or windows on official website of Geos
The dissolve function takes a vector of polygons and an optional buffer_size parameter,
and returns a single, merged polygon. If buffer_size is not provided, it defaults to 0.000000001.

use geo::Polygon;
use turf_rs::dissolve;
fn main() {
// Create some polygons to dissolve
let polygon1 = Polygon::new(
vec![
(0.0, 0.0),
(1.0, 1.0),
(1.0, 0.0),
(0.0, 0.0),
]
.into(),
vec![],
);
let polygon2 = Polygon::new(
vec![
(1.0, 0.0),
(2.0, 1.0),
(2.0, 0.0),
(1.0, 0.0),
]
.into(),
vec![],
);
let polygons = vec![polygon1, polygon2];
// Without buffer size
match dissolve(polygons.clone(), None) {
Ok(result) => {
println!("Polygons dissolved successfully!");
println!(
"Joined {} polygons into {}.",
result.polygons_joined, result.all_polygons
);
}
Err(e) => {
eprintln!("Error dissolving polygons: {}", e);
}
}
// With buffer size
match dissolve(polygons.clone(), Some(10.0)) {
Ok(result) => {
println!("Polygons dissolved successfully with buffer!");
println!(
"Joined {} polygons into {}.",
result.polygons_joined, result.all_polygons
);
}
Err(e) => {
eprintln!("Error dissolving polygons: {}", e);
}
}
}
The clear_polygons function simplifies polygon geometries by removing
duplicate and collinear points.

use geo::Polygon;
use turf_rs::clean_coords;
fn main() {
// Create a polygon with redundant vertices
let polygon = Polygon::new(
vec![
(0.0, 0.0),
(0.5, 0.0), // Collinear point
(1.0, 0.0),
(1.0, 1.0),
(1.0, 1.0), // Duplicate point
(0.0, 1.0),
(0.0, 0.0),
].into(),
vec![],
);
let result = clean_coords(vec![polygon]);
println!("Polygon cleaned successfully!");
println!("Original vertices: {}", result.origal_vertices);
println!("Cleaned vertices: {}", result.cleaned_vertices);
}
Add the following to your Cargo.toml file:
[dependencies]
turf-rs = "0.1.0"
We welcome contributions from the community! If you have an idea for a new feature, a bug fix, or an improvement to the documentation, please open an issue or submit a pull request on our GitHub repository.
Together, we can make turf-rs the best geospatial library for Rust!
This project is licensed under the terms of the MIT license or the Apache License 2.0.