GeoPython 2020

Turfpy a new way to do spatial analysis in Python
2020-09-22, 09:35–09:55, Room 1

To show how TurfPy can be used to perform various geospatial functionality on geojson data.


Recently a few months back I had started to work with TurfPy. This is a Python library for performing geospatial data analysis. Actually it is a python alternative for turf.js. It is a new package so currently, it supports the MEASUREMENT and TRANSFORMATION functionalists of turf.js. The operation supported by Turfpy can be applied to any geometry type or on Feature objects which are basically standard geojson Features.

Turfpy: https://pypi.org/project/turfpy/
Turfpy Github: https://github.com/omanges/turfpy

The following are the functionalities for each section.

MEASUREMENT

  1. Bearing: Takes two Point Features and finds the geographic bearing between them.

  2. Distance: Calculates the distance between two Point Features. A point is containing latitude and longitude in decimal degrees and unit is optional.

  3. Area: This function calculates the area of the Geojson object given as input.

  4. Bounding box: This function is used to generate bounding box coordinates for given geojson, the input can be a geometry type or it can be a Feature or it can be a FeatureCollection.

  5. Bounding box Polygon: To generate a Polygon Feature for the bounding box generated using the bounding box functionality above.

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

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

  8. Length: Takes a geojson and measures its length in the specified units.

  9. Destination: Takes a Point and calculates the location of a destination point given a distance in degrees, radians, miles, or kilometers and bearing in degrees.

  10. Centroid: Takes one or more features and calculates the centroid using the mean of all vertices.

  11. Along: This function is used to identify a Point Feature at a specified distance along a LineString.

  12. Midpoint: This function is used to get midpoint between any two points.

  13. Nearest Point: Takes a reference Point Feature and FeatureCollection of point features and returns the point from the FeatureCollection closest to the reference Point Feature.

  14. Point On Feature: Takes a Feature or FeatureCollection and returns a Point guaranteed to be on the surface of the feature.

  15. Point In Polygon: Takes a Point or a Point Feature and Polygon or Polygon Feature as input and returns True if Point is in given Feature.

  16. Point To Line Distance: Returns the minimum distance between a Point and any segment of the LineString.

  17. Rhumb Bearing: Takes two 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).

  18. Rhumb Destination: Returns the destination Point having traveled the given distance along a Rhumb line

  19. Rhumb Distance: Calculates the distance along a rhumb line between two points in degrees, radians, miles, or kilometers.

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

TRANSFORMATION

  1. Circle: Takes a Point and calculates the circle polygon given a radius in degrees, radians, miles, or kilometers; and steps for precision.

  2. Bounding box clip: Takes a Feature or geometry and a bounding box and clips the feature to the bounding box.

  3. Bezier spline: Takes a line and returns a curved version by applying a Bezier spline algorithm.

  4. Concave Hull: Generate a concave hull for the given feature or Feature Collection.

  5. Convex Hull: Generate convex hull for the given feature or Feature Collection.

  6. Intersect: Takes polygons and finds their intersection.

  7. Union: Given a list of features or FeatureCollection return union of those.

  8. Dissolve: Take FeatureCollection or a list of features to dissolve based on property_name provided.

  9. Difference: Find the difference between the given two features.