Welcome to pyturf’s documentation!¶
pyturf
is a powerful geospatial library written in python, based on turf.js,
a popular library written in javascript. It follows the same modular structure and maintains the same functionality as the original
modules in that library for maximum compatibility.
It includes traditional geospatial operations, as well as helper functions for creating and manipulating GeoJSON data.
Installation¶
$ pip install pyturf
Usage¶
Most pyturf
modules expect as input GeoJSON features or a collection of these, which can be the following:
Point / MultiPoint
LineString / MultiLineString
Polygon / MultiPolygon
These can either be defined as a python dictionary or as objects from pyturf
helper classes.
# example as a dictionary:
point1 = {
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
# Note order: longitude, latitude.
"coordinates": [-73.988214, 40.749128]
}
}
...
# Example using objects from helper classes
from turf import point
# Note order: longitude, latitude.
point1 = point([-73.988214, 40.749128])
In order to use the modules, one can import directly from pyturf
, such as:
from turf import distance, point
point1 = point([-73.988214, 40.749128])
point2 = point([-73.838432, 40.738484])
dist = distance(point1, point2, {"units": "miles"})
Contributor Guide¶
If you want to contribute to the project, fork this repository and check the contributing guide: