Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dartclub/turf_dart
A turf.js-like geospatial analysis library working with GeoJSON, written in pure Dart.
https://github.com/dartclub/turf_dart
dart flutter geojson geojson-parser geospatial turf
Last synced: about 16 hours ago
JSON representation
A turf.js-like geospatial analysis library working with GeoJSON, written in pure Dart.
- Host: GitHub
- URL: https://github.com/dartclub/turf_dart
- Owner: dartclub
- License: mit
- Created: 2020-08-28T00:29:11.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-10-17T09:29:41.000Z (4 months ago)
- Last Synced: 2025-02-13T02:11:11.286Z (8 days ago)
- Topics: dart, flutter, geojson, geojson-parser, geospatial, turf
- Language: Dart
- Homepage: https://pub.dev/packages/turf
- Size: 1.4 MB
- Stars: 73
- Watchers: 3
- Forks: 31
- Open Issues: 20
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
![]()
A TurfJs-like geospatial analysis library written in pure Dart.
[](https://pub.dev/packages/turf)


–> Join our Dart / Flutter GIS Community on Discord <–
TurfDart is a Dart library for [spatial analysis](https://en.wikipedia.org/wiki/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](https://github.com/dartclub/geotypes), a lightweight dart library that provides a strong GeoJSON object model and fully [RFC 7946](https://tools.ietf.org/html/rfc7946) compliant serializers.
Most of the functionality is a translation from [turf.js](https://github.com/Turfjs/turf), the progress can be found [here](Progress.md).
## Get started
- Get the [Dart tools](https://dart.dev/tools)
- Install the library with `dart pub add turf`
- Import the library in your code and use it. For example:```dart
import 'package:turf/helpers.dart';
import 'package:turf/src/line_segment.dart';Feature poly = Feature(
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(
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](https://datatracker.ietf.org/doc/html/rfc7946#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.