A TurfJs-like geospatial analysis library written in pure Dart.
–> Join our Dart / Flutter GIS Community on Discord <–
TurfDart is a Dart library for spatial analysis. It includes traditional spatial operations, helper functions for creating GeoJSON data, and data classification and statistics tools. You can use TurfDart in your Flutter applications on the web, mobile and desktop or in pure Dart applications running on the server.
As the foundation, we are using Geotypes, a lightweight dart library that provides a strong GeoJSON object model and fully RFC 7946 compliant serializers.
Most of the functionality is a translation from turf.js, the progress can be found here.
Get started
- Get the Dart tools
- Install the library with
dart pub add turf - Import the library in your code and use it. For example:
import 'package:turf/helpers.dart';
import 'package:turf/src/line_segment.dart';
Feature<Polygon> poly = Feature<Polygon>(
geometry: Polygon(coordinates: [
[
Position(0, 0),
Position(2, 2),
Position(0, 1),
Position(0, 0),
],
[
Position(0, 0),
Position(1, 1),
Position(0, 1),
Position(0, 0),
],
]),
);
void main() {
var total = segmentReduce<int>(
poly,
(previousValue, currentSegment, initialValue, featureIndex,
multiFeatureIndex, geometryIndex, segmentIndex) {
if (previousValue != null) {
previousValue++;
}
return previousValue;
},
0,
combineNestedGeometries: false,
);
print(total);
// total == 6
}
GeoJSON Object Model

Notable Design Decisions
- Nested
GeometryCollections(as described in RFC 7946 section 3.1.8) are not supported which takes a slightly firmer stance than the "should avoid" language in the specification
Tests and Benchmarks
Tests are run with dart test and benchmarks can be run with
dart run benchmark
Any new benchmarks must be named *_benchmark.dart and reside in the
./benchmark folder.
Libraries
- along
- Takes a LineString and returns a Point at a specified distance along the line.
- area
- Calculates the geodesic area of GeoJSON geometries in square meters.
- bbox
- Computes the bounding box for any GeoJSON object including FeatureCollection.
- bbox_polygon
- Converts a bounding box (
BBox) into an equivalent Polygon feature. - bearing
- Calculates the geographic bearing (and rhumb bearing) between two Points.
- boolean
- Boolean spatial predicates for GeoJSON geometries (contains, within, equal, etc.).
- center
- Computes the absolute center Point of a GeoJSON object's bounding box.
- center_of_mass
- Computes the center of mass Point of a GeoJSON polygon.
- centroid
- Computes the centroid Point of any GeoJSON object using the mean of its vertices.
- circle
- Generates a circular Polygon of given radius around a center Point.
- clean_coords
- Removes redundant coordinates from a GeoJSON Feature or geometry.
- clusters
- Iterators and reducers for working with clustered features.
- combine
- Combines a FeatureCollection of like geometries into multi-feature equivalents.
- destination
- Calculates a destination Point given an origin, distance, and bearing.
- distance
- Calculates the geodesic and rhumb-line distance between two Points.
- envelope
- Computes the rectangular Polygon envelope (bounding box polygon) of any GeoJSON object.
- explode
- Explodes a GeoJSON object into a FeatureCollection of Points representing every vertex.
- extensions
- Convenience extension methods on GeoJSON types for iteration and metadata access.
- flatten
- Flattens any GeoJSON object into a FeatureCollection of single geometries.
- flip
- Swaps the x/y coordinate order of any GeoJSON geometry.
- helpers
- Common helper constants and unit conversion utilities used across turf functions.
- invariant
- Invariant helpers that extract or validate coordinates and geometry types from GeoJSON inputs.
- length
- Computes the length of a LineString or other linear GeoJSON geometry.
- line_intersect
- Finds the intersecting Points between two GeoJSON linestrings or polygons.
- line_overlap
- Finds shared (overlapping) segments between two linear or polygon GeoJSON geometries.
- line_segment
- Iterates and reduces over the 2-vertex line segments of any GeoJSON object.
- line_slice
- Returns the section of a LineString between two Points.
- line_slice_along
- Returns the section of a LineString between specified start and stop distances.
- line_to_polygon
- Converts a LineString or MultiLineString into a Polygon or MultiPolygon.
- lineclip
- Clips lines and polygons against a rectangular bounding box (Cohen-Sutherland / Sutherland-Hodgman).
- meta
- Iterators and reducers (
coordEach,featureEach,flattenEach, etc.) for traversing GeoJSON. - midpoint
- Calculates the midpoint Point between two Points on a great-circle path.
- nearest_point
- Finds the closest Point in a FeatureCollection to a reference Point.
- nearest_point_on_line
- Finds the closest Point along a LineString to a reference Point.
- point_on_feature
- Returns a Point guaranteed to lie on the surface of the given GeoJSON feature.
- point_to_line_distance
- Calculates the minimum distance from a Point to a LineString.
- polygon_smooth
- Smooths the outline of a Polygon using Chaikin's algorithm.
- polygon_tangents
- Computes the tangent Points on a polygon's exterior from an external point.
- polygon_to_line
- Converts a Polygon or MultiPolygon into a LineString or MultiLineString.
- polyline
- Encodes and decodes LineString geometries using Google's polyline algorithm.
- random_linestring
- Generates random LineString features within a bounding box for testing and demos.
- simplify
- Simplifies a GeoJSON geometry using the Ramer-Douglas-Peucker algorithm.
- square
- Expands a bounding box into the smallest enclosing square bounding box.
- to_mercator
- Projects WGS84 GeoJSON geometries into Web Mercator (EPSG:3857) coordinates.
- to_wgs84
- Unprojects Web Mercator (EPSG:3857) GeoJSON geometries back to WGS84 longitude/latitude.
- transform
- Geometric transformations such as rotation and Mercator/WGS84 reprojection.
- truncate
- Truncates the precision of GeoJSON coordinates to a configurable number of decimals.
- turf
- A turf.js-like geospatial analysis library for Dart.