measurements library
A collection of measurement functions.
All measurements are in meters or square meters.
All measurements are in the EPSG:4326
coordinate system.
Example:
import 'package:geodart/measurements.dart';
// Calculate the distance between two points.
double distance = measure.distance(Point(0, 0), Point(1, 1));
// Calculate the bearing between two points.
double bearing = measure.bearing(Point(0, 0), Point(1, 1));
// Calculate the length of a LineString
LineString([Coordinate(1, 2), Coordinate(3, 4)]).length; // 314283.2550736839
// Calculate the area of a Polygon
Polygon([
LinearRing([Coordinate(1, 2), Coordinate(3, 4), Coordinate(5, 6), Coordinate(1, 2)])
]).area; // 12.5
Functions
-
area(
Feature poly) → double - Calculates the area of a Polygon or MultiPolygon, in square meters. Also accessible from Polygon.area and MultiPolygon.area. The area is calculated using the Shoelace formula.
-
bearing(
Point from, Point to) → double - Computes the bearing between two Points. The bearing is the angle from the north to the second point.
-
distance(
Point from, Point to) → double - Computes the distance between two Points in meters. The distance is the straight-line distance between the two points. The distance is calculated using the Haversine formula.
-
length(
Feature line) → double - Calculates the length of a LineString or MultiLineString, in meters. Also accessible from LineString.length and MultiLineString.length. The length is calculated using the Haversine formula. Compare this snippet from lib/src/measure/length.dart: