geojson 0.2.1 copy "geojson: ^0.2.1" to clipboard
geojson: ^0.2.1 copied to clipboard

outdated

Manipulate geojson data. Load and parse geojson from a string or a file.

Geojson #

pub package

Utilities to work with geojson data in Dart.

Example #

import 'dart:io';
import 'package:geojson/geojson.dart';

void main() async {
  multipolygons();
  lines();
}

void multipolygons() async {
  final file = File("lakes_of_europe.geojson");
  final features = await featuresFromGeoJsonFile(file, nameProperty: "label");
  for (final feature in features.collection) {
    final geom = feature.geometry as MultiPolygon;
    for (final polygon in geom.polygons) {
      print("Polygon ${polygon.name}");
      for (final geoSerie in polygon.geoSeries) {
        print("- ${geoSerie.geoPoints.length} geopoints");
      }
    }
  }
}

void lines() async {
  final file = File("railroads_of_north_america.geojson");
  final features = await featuresFromGeoJsonFile(file);
  for (final feature in features.collection) {
    print("${feature.geometry.geoSerie.name}: " +
        "${feature.geometry.geoSerie.geoPoints.length} geopoints");
  }
}

Api #

featuresFromGeoJson: get features from geojson string data. Parameters:

  • data: a string with the geojson data, required
  • nameProperty: the property used for the geoserie name, automaticaly set if null
  • verbose: print data if true

featuresFromGeoJsonFile: get features from a geojson file. Parameters:

  • file: the file to load, required
  • nameProperty: the property used for the geoserie name, automaticaly set if null
  • verbose: print data if true
61
likes
0
pub points
91%
popularity

Publisher

unverified uploader

Manipulate geojson data. Load and parse geojson from a string or a file.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

geopoint, meta, pedantic

More

Packages that depend on geojson