Registry / data / turfpy

turfpy

JSON →
library0.0.8pypypi✓ verified 87d ago

A Python library for geospatial data analysis that reimplements turf.js. Current version 0.0.8, released periodically with incremental improvements.

pip install turfpy
INSTALL
IMPORT
SIG · TURFPY
T
turfpy
datapythonv0.0.8
Install
12.0s avg
Import
Disk
407MB
Pass rate
4/ 10
Env Coverage4 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.0.8 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✕ build_error
✓ 13.3s
py 3.11
✕ build_error
✓ 12.6s
py 3.12
✕ build_error
✓ 12.9s
py 3.13
✕ build_error
✕ build_error
py 3.9
✕ build_error
✓ 9.1s
407MB installed
● package 407MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

turfpy
import turfpy
from turfpy import ...
Common pattern: import turfpy and call turfpy.function().
measurement
from turfpy import measurement
import measurement
measurement is a submodule, not top-level.

Calculate distance between two points using turfpy.

import turfpy from turfpy import measurement from geojson import Point, Feature point1 = Feature(geometry=Point((-3.0, 53.0))) point2 = Feature(geometry=Point((-2.0, 55.0))) distance = measurement.distance(point1, point2) print(f'Distance: {distance}')
Debug
Known issues
gotchaturfpy expects GeoJSON Feature objects, not raw shapely geometries. Convert polygons to GeoJSON features before passing to functions like area or length.
fix
Use geojson library to wrap geometries: Feature(geometry=Polygon(...))
affects: all
deprecatedBoolean operations like intersect, union, difference were moved to a separate submodule in v0.0.8. Importing from top-level turfpy may break.
fix
Use from turfpy import boolean_ops or from turfpy.boolean_ops import ...
affects: >=0.0.8
gotchaThe area function returns square meters for geographic coordinates, not degrees. If you need other units, convert beforehand.
fix
Use turfpy.measurement.area with appropriate coordinate system or convert output.
affects: all
Errors
Common errors & fixes
AttributeError: module 'turfpy' has no attribute 'distance'
distance is in turfpy.measurement submodule, not top-level.
fix
Use from turfpy import measurement; measurement.distance(...)
TypeError: Object of type Polygon is not JSON serializable
turfpy expects GeoJSON Feature or geometry dict, not raw shapely object.
fix
Convert to GeoJSON: from geojson import Feature; Feature(geometry=your_shapely_polygon)
ModuleNotFoundError: No module named 'turfpy'
turfpy not installed or installed in wrong environment.
fix
Run 'pip install turfpy' or check that you're in the correct Python environment.
Upgrade
Version history
0.0.8latest on PyPI · released Nov 11, 2024
Audit
Dependencies
geopandasrequiredused for spatial operations
shapelyrequiredgeometry backend
numpyrequirednumerical operations
Agent activity
29 hits · last 30 days
node
24
Amazon
1
OpenAI (training)
1
Resources