Search packages, repositories and app categories

Package detailsv0.0.14

turf

A turf.js-like geospatial analysis library working with GeoJSON, written in pure Dart.

AndroidiOSWebmacOSWindowsLinux
30-day downloads
176K
Likes
51
Pub points
150

Install package

flutter pub add turf

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

Turf is a geospatial analysis library for Dart, inspired by turf.js, designed to work with GeoJSON data. It provides a suite of tools for performing spatial operations such as distance calculations, buffering, intersection, and more, all in pure Dart. Ideal for applications requiring real-time geographic computations without relying on native platform code. The library supports multiple platforms including Android, iOS, Web, macOS, Windows, and Linux, making it highly versatile for cross-platform development. Its lightweight nature and compatibility with Flutter make it suitable for maps and location-based features.

Use cases

  • Geospatial data processing
  • Map-based analytics
  • Location-aware applications
  • Real-time spatial calculations
  • GeoJSON manipulation

Key features

  • Pure Dart implementation
  • Supports GeoJSON
  • Cross-platform compatibility
  • Turf.js-like API
  • Extensive spatial operations

Suitable for

  • Flutter developers
  • GIS applications
  • Mobile and web mapping
  • Data scientists working with location data
  • Applications needing offline geospatial logic

Considerations

  • Requires GeoJSON input format
  • Limited to basic geospatial functions
  • No built-in map rendering
  • Performance depends on data size
  • Not optimized for very large datasets

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.


TurfDart Logo

A TurfJs-like geospatial analysis library written in pure Dart.


pub package dart unit tests dart publish License: MIT

–> 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

polymorphism

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.

Categories

Dependencies

Dependency list 6 items

Source repository

Projects using this package