Claude Code skill for Turf.js spatial analysis.
中文文档 | Contributing | Changelog
Tip: If installed via
npx skills add zhyt1985/turf-skills, usenpx turf-skillsdirectly without global installation.
# npm global install
npm install -g turf-skills
# Or clone and link
git clone https://github.com/zhyt1985/turf-skills.git
cd turf-skills && npm install && npm link
# Install as skill
mkdir -p ~/.claude/skills/turf-skills
ln -s $(which turf-skills) ~/.claude/skills/turf-skills/
cp SKILL.md ~/.claude/skills/turf-skills/npm install -g turf-skills
npx turf-skills --action distance --input '{"type":"Point","coordinates":[120,30]}' --input2 '{"type":"Point","coordinates":[121,31]}'| Category | Actions |
|---|---|
| Measurement | distance, area, length, bearing, destination, midpoint, center, centroid, centerOfMass, along, bbox, bboxPolygon, envelope |
| Query | booleanPointInPolygon, booleanContains, booleanCrosses, booleanDisjoint, booleanEqual, booleanIntersects, booleanOverlap, booleanWithin, booleanParallel, booleanPointOnLine, nearestPoint |
| Transformation | buffer, union, intersect, difference, simplify, convex, concave, dissolve, voronoi, tin, bezierSpline, transformRotate, transformScale, transformTranslate |
| Helpers | point, lineString, polygon, multiPoint, multiLineString, multiPolygon, featureCollection, randomPoint, randomLineString, randomPolygon |
| Interpolation | interpolate, isobands, isolines, hexGrid, pointGrid, squareGrid, triangleGrid |
| Clustering | clustersKmeans, clustersDbscan |
# Distance between two points
npx turf-skills --action distance \
--input '{"type":"Point","coordinates":[120,30]}' \
--input2 '{"type":"Point","coordinates":[121,31]}'
# Point in polygon
npx turf-skills --action booleanPointInPolygon \
--input '{"type":"Point","coordinates":[120.5,30.5]}' \
--input2 '{"type":"Polygon","coordinates":[[[120,30],[121,30],[121,31],[120,31],[120,30]]]}'
# Buffer
npx turf-skills --action buffer \
--input '{"type":"Point","coordinates":[120,30]}' \
--radius 5 --units kilometers
# Read from file
npx turf-skills --action area --file polygon.geojson
# Hex grid
npx turf-skills --action hexGrid --bbox '[120,30,121,31]' --cellSide 5
# K-means clustering
npx turf-skills --action clustersKmeans --file points.geojson --numberOfClusters 5# Beijing to Shanghai distance → 1068 km
npx turf-skills --action distance \
--input '{"type":"Point","coordinates":[116.397428,39.90923]}' \
--input2 '{"type":"Point","coordinates":[121.473701,31.230416]}' \
--units kilometers
# Is Tiananmen inside Beijing's 5th Ring Road? → true
npx turf-skills --action booleanPointInPolygon \
--input '{"type":"Point","coordinates":[116.397428,39.90923]}' \
--input2 '{"type":"Polygon","coordinates":[[[116.1,39.7],[116.8,39.7],[116.8,40.1],[116.1,40.1],[116.1,39.7]]]}'
# Create a 5km buffer around a point
npx turf-skills --action buffer \
--input '{"type":"Point","coordinates":[116.397428,39.90923]}' \
--radius 5 --units kilometers
# Polygon union
npx turf-skills --action union \
--input '{"type":"Polygon","coordinates":[[[120,30],[121,30],[121,31],[120,31],[120,30]]]}' \
--input2 '{"type":"Polygon","coordinates":[[[120.5,30.5],[121.5,30.5],[121.5,31.5],[120.5,31.5],[120.5,30.5]]]}'
# Generate hex grid for a region (28 hexagons)
npx turf-skills --action hexGrid --bbox '[116,39,117,40]' --cellSide 10 --units kilometers
# K-means clustering into 3 groups
npx turf-skills --action clustersKmeans --file points.geojson --numberOfClusters 3
# Create a point with properties
npx turf-skills --action point \
--coordinates '[116.397428,39.90923]' \
--properties '{"name":"Tiananmen"}'
# Convex hull of a point set
npx turf-skills --action convex --file points.geojson
# Find nearest point in a collection
npx turf-skills --action nearestPoint \
--input '{"type":"Point","coordinates":[120.3,30.3]}' \
--file2 points-collection.geojson
# Line length in kilometers
npx turf-skills --action length --file line.geojson --units kilometers
# Output result to file
npx turf-skills --action buffer --file point.geojson --radius 10 --output result.geojson| Option | Description |
|---|---|
--action <name> |
Turf function name (required) |
--input <geojson> |
First GeoJSON input |
--input2 <geojson> |
Second GeoJSON input |
--file <path> |
Read first input from file |
--file2 <path> |
Read second input from file |
--output <path> |
Write result to file |
--units <km|mi|m> |
Distance units |
--radius <n> |
Buffer radius |
--bbox <json> |
Bounding box |
--cellSide <n> |
Grid cell size |
--coordinates <json> |
Coordinates (for helpers) |
--properties <json> |
Properties (for helpers) |
--list |
List all actions |
--help |
Show help |
After installing as a Claude Code skill, you can use natural language to invoke spatial analysis. Claude will automatically translate your request into the appropriate turf-skills command.
| You say | Claude runs |
|---|---|
| "Calculate the distance from Beijing to Shanghai" | npx turf-skills --action distance --input '{"type":"Point","coordinates":[116.397428,39.90923]}' --input2 '{"type":"Point","coordinates":[121.473701,31.230416]}' --units kilometers |
| "Is Tiananmen inside this polygon?" | npx turf-skills --action booleanPointInPolygon --input '...' --input2 '...' |
| "Create a 5km buffer around this point" | npx turf-skills --action buffer --input '...' --radius 5 --units kilometers |
| "Compute the convex hull of points.geojson and save to result.geojson" | npx turf-skills --action convex --file points.geojson --output result.geojson |
| "Calculate the area of polygon.geojson" | npx turf-skills --action area --file polygon.geojson |
| "Generate a hex grid for the Beijing area" | npx turf-skills --action hexGrid --bbox '[116,39,117,40]' --cellSide 10 --units kilometers |
| "Cluster these points into 3 groups" | npx turf-skills --action clustersKmeans --file points.geojson --numberOfClusters 3 |
| "Find the nearest point to [120.3, 30.3]" | npx turf-skills --action nearestPoint --input '...' --file2 points.geojson |
| "Merge these two polygons" | npx turf-skills --action union --input '...' --input2 '...' |
| "How long is this line in kilometers?" | npx turf-skills --action length --file line.geojson --units kilometers |
MIT