Measurement

along

turf.along(line, dist, options=None)[source]

Takes a LineString and returns a Point at a specified distance along the line

Parameters
  • line – input LineString

  • dist – distance along the line

  • options – optional parameters [options[“units”]=”kilometers”] can be degrees, radians, miles, or kilometers

Returns

Point dist units along the line

area

turf.area(features)[source]

Takes one or more features and returns their area in square meters.

Parameters

features – geojson input GeoJSON feature(s)

Returns

area in square meters

bbox

turf.bbox(features)[source]

Takes a set of features and returns a bounding box containing of all input features.

Parameters

features – any GeoJSON feature or feature collection

Returns

bounding box extent in [minX, minY, maxX, maxY] order

bbox-polygon

turf.bbox_polygon(bbox, options=None)[source]

Takes a bounding box and returns an equivalent Polygon feature.

Parameters
  • bbox – bounding box extent in [minX, minY, maxX, maxY] order

  • options – optional parameters [options[“properties”]={}] Translate GeoJSON Properties to Point [options[“id”]={}] Translate GeoJSON Id to Point

Returns

a Polygon representation of the bounding box

bearing

turf.bearing(start, end, options=None)[source]

Takes two points and finds the geographic bearing between them, i.e. the angle measured in degrees from the north line (0 degrees)

Parameters
  • start – starting point [lng, lat] or Point feature

  • end – ending point [lng, lat] or Point feature

  • options – dictionary with options: [options[“final”]] - calculates the final bearing if true

Returns

bearing in decimal degrees, between -180 and 180 (positive clockwise)

center

turf.center(features, options=None)[source]

Takes a Feature or FeatureCollection and returns the absolute center point of all features.

Parameters
  • features – features or collection of features

  • options – optional parameters [options[“properties”]={}] Translate GeoJSON Properties to Point [options[“bbox”]={}] Translate GeoJSON BBox to Point [options[“id”]={}] Translate GeoJSON Id to Point

Returns

a Point feature at the absolute center point of all input features

centroid

turf.centroid(features, options=None)[source]

Takes one or more features and calculates the centroid using the mean of all vertices. This lessens the effect of small islands and artifacts when calculating the centroid of a set of polygons.

Parameters
  • features – GeoJSON features to be centered

  • options – optional parameters [options[“properties”]={}] Translate GeoJSON Properties to Point

Returns

a Point feature corresponding to the centroid of the input features

destination

turf.destination(origin, distance, bearing, options=None)[source]

Takes a Point and calculates the location of a destination point given a distance in degrees, radians, miles, or kilometers; and bearing in degrees. This uses the [Haversine formula](http://en.wikipedia.org/wiki/Haversine_formula) to account for global curvature.

Parameters
  • origin – starting point

  • distance – distance from the origin point

  • bearing – bearing ranging from -180 to 180

  • options – optional parameters [options[“units”]=’kilometers’] miles, kilometers, degrees, or radians [options[“properties”]={}] Translate properties to Point

Returns

destination GeoJSON Point feature

distance

turf.distance(start, end, options=None)[source]

Calculates the distance between two Points in degrees, radians, miles, or kilometers. This uses the [Haversine formula](http://en.wikipedia.org/wiki/Haversine_formula) to account for global curvature.

Parameters
  • start – starting point [lng, lat] or Point feature

  • end – ending point [lng, lat] or Point feature

  • options – dictionary with units as an attribute. Can be degrees, radians, miles, or kilometers

Returns

distance between the 2 points

envelope

turf.envelope(features, *args)[source]

Takes any number of features and returns a rectangular Polygon that encompasses all vertices.

Parameters

features – any GeoJSON feature or feature collection

Returns

bounding box extent in [minX, minY, maxX, maxY] order

length

turf.length(features, options=None)[source]

Calculates the total length of the input Feature / FeatureCollection in the specified units.

Parameters
  • features – a Feature / FeatureCollection of types LineString, MultiLineString, Polygon or MultiPolygon

  • options – optional parameters [options[“units”]=kilometers] can be degrees, radians, miles, or kilometers

Returns

the measured distance

midpoint

turf.midpoint(point1, point2)[source]

Takes two point features and returns a point midway between them. The midpoint is calculated geodesically, meaning the curvature of the earth is taken into account.

Parameters
  • point1 – first point

  • point2 – second point

Returns

a point midway between point 1 and point 2

nearest-point

turf.nearest_point(target: Union[Sequence, Dict, turf.helpers._features.Feature], features: GeoJson) → turf.helpers._features.Point[source]

Calculates the closest reference point from a feature collection towards a target point This calculation is geodesic.

Parameters
  • target – targetPoint the reference point

  • features – points against input point set

Returns

the closest point in the features set to the reference point

point-on-feature

turf.point_on_feature(features: GeoJSON) → turf.helpers._features.Point[source]

Takes a Feature or FeatureCollection and returns a {Point} guaranteed to be on the surface of the feature.

Given a {Polygon}, the point will be in the area of the polygon Given a {LineString}, the point will be along the string Given a {Point}, the point will the same as the input

Parameters

features – any GeoJSON feature or feature collection

Returns

Point GeoJSON Feature on the surface of input

point-to-line-distance

turf.point_to_line_distance(point: Union[Sequence, Dict, turf.helpers._features.Feature], line: Union[Sequence, Dict, turf.helpers._features.Feature], options: Dict = None)float[source]

Returns the minimum distance between a {Point} and a {LineString}, being the distance from a line the minimum distance between the point and any segment of the LineString

http://geomalgorithms.com/a02-_lines.html

Parameters
  • point – Point GeoJSON Feature or Geometry

  • line – LineString GeoJSON Feature or Geometry

  • options – Optional parameters [options[“units”]]: any supported unit (e.g. degrees, radians, miles…) [options[“method”]]: geodesic or ‘planar for distance calculation

Returns

distance between point and line

polygon-tangents

turf.polygon_tangents(start_point: PointFeature, polygon: PolygonFeature) → turf.helpers._features.FeatureCollection[source]

Finds the tangents of a {Polygon or(MultiPolygon} from a {Point}.

more: http://geomalgorithms.com/a15-_tangents.html

Parameters
  • point – point [lng, lat] or Point feature to calculate the tangent points from

  • polygon – polygon to get tangents from

Returns

Feature Collection containing the two tangent points

rhumb-bearing

turf.rhumb_bearing(origin: Union[Sequence, Dict, turf.helpers._features.Feature], destination: Union[Sequence, Dict, turf.helpers._features.Feature], options: Dict = None)float[source]

Takes two {Point|points} and finds the bearing angle between them along a Rhumb line * i.e. the angle measured in degrees start the north line (0 degrees)

https://en.wikipedia.org/wiki/Rhumb_line

Parameters
  • start – starting point [lng, lat] or Point feature

  • end – ending point [lng, lat] or Point feature

  • options – Optional parameters [options[“final”]]: Calculates the final bearing if True

Returns

bearing from north in decimal degrees

rhumb-destination

turf.rhumb_destination(features: Dict, options: Dict = None) → turf.helpers._features.Point[source]

Returns the destination {Point} having travelled the given distance along a Rhumb line from the origin Point with the (varant) given bearing.

# https://en.wikipedia.org/wiki/Rhumb_line

Parameters
  • features – any GeoJSON feature or feature collection

  • properties – specification to calculate the rhumb line [options[“distance”]=100] distance from the starting point [options[“bearing”]=180] varant bearing angle ranging from -180 to 180 degrees from north [options[“units”]=kilometers] units: specifies distance (can be degrees, radians, miles, or kilometers)

  • options – optional parameters also be part of features[“properties”] [options[“units”]={}] can be degrees, radians, miles, or kilometers [options[“properties”]={}] Translate GeoJSON Properties to Point [options[“id”]={}] Translate GeoJSON Id to Point

Returns

a FeatureDestination point.

rhumb-distance

turf.rhumb_distance(origin, destination, options: Dict = None)float[source]

Calculates the rhumb distance between two Points. Units are defined in helpers._units

# https://en.wikipedia.org/wiki/Rhumb_line

Parameters
  • start – starting point [lng, lat] or Point feature

  • end – ending point [lng, lat] or Point feature

  • options – dictionary with units as an attribute. Units are defined in helpers._units

Returns

distance between the 2 points

square

turf.square(bbox)[source]

Takes a bounding box and calculates the minimum square bounding box that would contain the input.

Parameters

bbox – bounding box extent in [minX, minY, maxX, maxY] order

Returns

a square surrounding bbox

great-circle

turf.great_circle(start, end, options=None)[source]

Returns the great circle route as LineString

Parameters
  • start – source point feature

  • end – destination point feature

  • options – Optional parameters [options[“properties”]={}] line feature properties [options.npoints=100] number of points

Returns

great circle line feature