Module Categories
Purpose and Scope
This document explains the functional categorization of Turf.js modules into seven distinct groups based on their operational purpose. The 100+ packages in the Turf.js monorepo are organized by the type of geospatial operation they perform, ranging from basic measurements to complex geometric algorithms. This categorization helps users discover appropriate modules for their use cases and understand the library's operational capabilities.
For information about the foundational utilities that underpin all categories, see Foundation Modules. For details on how modules depend on each other across tiers, see Dependency Hierarchy.
Category Overview
The Turf.js modules are organized into seven functional categories, each serving a distinct operational domain. All categories depend on the foundation layer (@turf/helpers, @turf/meta, @turf/invariant) described in Foundation Modules.
Measurement Modules
Measurement modules calculate quantitative properties of geographic features, including distances, bearings, areas, and lengths. These modules typically implement geodesic calculations using the WGS84 ellipsoid.
Core Measurement Operations
Module Listing
| Module | Description | Key Dependencies |
|---|---|---|
@turf/distance | Geodesic distance between two points | @turf/helpers, @turf/invariant |
@turf/bearing | Geographic bearing between points | @turf/helpers, @turf/invariant |
@turf/destination | Calculate destination point from origin, distance, and bearing | @turf/helpers, @turf/invariant |
@turf/along | Point at specified distance along a line | @turf/bearing, @turf/destination, @turf/distance |
@turf/area | Geodesic area of polygons in square meters | @turf/helpers, @turf/meta |
@turf/length | Total length of LineStrings | @turf/helpers, @turf/meta |
@turf/bbox | Calculate bounding box | @turf/helpers, @turf/meta |
@turf/midpoint | Midpoint between two points | @turf/bearing, @turf/destination, @turf/distance |
Boolean Predicate Modules
Boolean predicate modules perform spatial relationship tests between geometries, returning true or false. These modules implement standard topological predicates from the DE-9IM spatial model.
Boolean Operations Mapping
Predicate Categories
| Category | Modules | Typical Use Case |
|---|---|---|
| Containment | boolean-contains, boolean-within, boolean-point-in-polygon | Determine if features are inside/outside boundaries |
| Intersection | boolean-intersects, boolean-crosses, boolean-overlap | Detect geometric overlap or crossing |
| Separation | boolean-disjoint, boolean-touches | Test spatial separation or adjacency |
| Equivalence | boolean-equal | Compare geometries for equality |
| Validation | boolean-valid, boolean-clockwise, boolean-concave | Validate geometric properties |
| Line Relationships | boolean-parallel, boolean-point-on-line | Test linear feature relationships |
Transformation Modules
Transformation modules modify the geometry or coordinates of features without changing their fundamental structure. These operations include coordinate manipulation, shape modification, and precision control.
Transformation Operations
Module Characteristics
| Module | Input Type | Output Type | External Dependencies |
|---|---|---|---|
@turf/buffer | Point/Line/Polygon | Polygon | @turf/jsts, d3-geo |
@turf/simplify | Line/Polygon | Line/Polygon | @turf/clean-coords |
@turf/truncate | Any Feature | Same Feature | None |
@turf/flip | Any Feature | Same Feature | @turf/clone, @turf/meta |
@turf/clean-coords | Line/Polygon | Line/Polygon | None |
@turf/transform-rotate | Any Feature | Same Feature | @turf/clone, @turf/meta |
@turf/transform-scale | Any Feature | Same Feature | @turf/clone, @turf/meta |
@turf/transform-translate | Any Feature | Same Feature | @turf/clone, @turf/meta |
Geometric Operations
Geometric operations perform complex algorithmic transformations on features, including boolean operations, hull calculations, and line processing. These modules often depend on external computational geometry libraries.
Boolean Set Operations
Hull and Envelope Operations
Line Processing Modules
| Module | Operation | Dependencies |
|---|---|---|
@turf/line-split | Split line by point or line | @turf/meta, @turf/nearest-point-on-line |
@turf/line-segment | Break line into segments | @turf/meta |
@turf/line-chunk | Divide line into equal chunks | @turf/meta, @turf/length |
@turf/line-intersect | Find intersection points | sweepline-intersections |
@turf/line-overlap | Find overlapping portions | @turf/meta |
@turf/line-offset | Parallel offset lines | @turf/meta |
@turf/line-slice | Extract segment between points | @turf/nearest-point-on-line |
@turf/line-slice-along | Extract segment by distance | @turf/along, @turf/length |
Complex Polygon Operations
| Module | Description | Key External Library |
|---|---|---|
@turf/union | Combine multiple polygons | polyclip-ts |
@turf/intersect | Find shared polygon area | polyclip-ts |
@turf/difference | Subtract one polygon from another | polyclip-ts |
@turf/concave | Generate concave hull | topojson-server, topojson-client |
@turf/convex | Generate convex hull | concaveman |
@turf/unkink-polygon | Fix self-intersections | rbush |
@turf/mask | Create inverted polygon | polyclip-ts |
@turf/dissolve | Merge polygons by property | polyclip-ts |
@turf/polygonize | Create polygons from lines | @turf/jsts |
@turf/tesselate | Triangulate polygon | earcut |
@turf/voronoi | Voronoi diagram | d3-delaunay |
Grid Generation Modules
Grid generation modules create regular tessellations of a bounding box area. These modules produce FeatureCollections of polygons or points arranged in geometric patterns.
Grid Types and Implementation
Grid Module Specifications
| Module | Cell Shape | Parameters | Special Dependencies |
|---|---|---|---|
@turf/hex-grid | Regular hexagon | cellSide, units, triangles option | @turf/distance, @turf/intersect |
@turf/square-grid | Square | cellSide, units, mask option | @turf/rectangle-grid |
@turf/triangle-grid | Equilateral triangle | cellSide, units, mask option | @turf/distance, @turf/intersect |
@turf/point-grid | N/A (points) | cellSide, units, mask option | @turf/boolean-within, @turf/distance |
@turf/rectangle-grid | Custom rectangle | cellWidth, cellHeight, units | None (base implementation) |
Cell Size and Units
All grid modules accept a cell size parameter and a units option. Supported units include:
'miles'- Statute miles'kilometers'- Metric kilometers'degrees'- Decimal degrees'radians'- Angular radians'meters','centimeters','feet', etc.
The unit conversion is handled by @turf/helpers functions convertLength() and convertArea().
Clustering and Analysis Modules
Clustering and analysis modules perform statistical operations, data interpolation, and pattern analysis on geospatial features. These modules often use spatial indexing for performance.
Clustering Algorithms
Center Calculations
Interpolation and Contour Generation
| Module | Purpose | Algorithm/Library | Output |
|---|---|---|---|
@turf/interpolate | Estimate values for unsampled locations | Inverse distance weighting | Point grid with interpolated values |
@turf/isolines | Generate contour lines | marchingsquares library | LineString contours at specified levels |
@turf/isobands | Generate filled contour polygons | marchingsquares library | Polygon bands between value ranges |
@turf/tin | Triangulated irregular network | Delaunay triangulation | Polygon triangles for surface modeling |
@turf/planepoint | Interpolate from TIN surface | Planar interpolation | Estimated z-value at point |
Statistical Analysis Modules
| Module | Analysis Type | Dependencies |
|---|---|---|
@turf/standard-deviational-ellipse | Directional distribution | @turf/center-mean, @turf/ellipse |
@turf/nearest-neighbor-analysis | Spatial clustering test | @turf/distance |
@turf/moran-index | Spatial autocorrelation | @turf/distance-weight |
@turf/quadrat-analysis | Point pattern analysis | @turf/square-grid |
Data Manipulation Modules
Data manipulation modules restructure GeoJSON data without performing geometric calculations. These operations transform feature collections, aggregate properties, or modify feature types.
Structure Transformation
Property Aggregation
Data Manipulation Operations
| Module | Operation | Input | Output | Use Case |
|---|---|---|---|---|
@turf/flatten | Flatten Multi* geometries | MultiPoint/MultiLineString/MultiPolygon | Multiple single geometries | Simplify structure for processing |
@turf/explode | Extract all coordinates | Any feature | Point for each coordinate | Get all vertices |
@turf/combine | Merge by geometry type | Mixed FeatureCollection | Multi* features by type | Group related features |
@turf/collect | Aggregate point values into polygons | Points + Polygons | Polygons with aggregated properties | Summarize data by zone |
@turf/tag | Transfer polygon properties to points | Points + Polygons | Points with polygon properties | Spatial join operation |
@turf/clone | Deep copy features | Any feature | Independent copy | Preserve original data |
@turf/sample | Random subset | FeatureCollection | Subset FeatureCollection | Statistical sampling |
@turf/random | Generate random features | None | Random Point/Line/Polygon | Testing and simulation |
Line and Polygon Conversions
| Module | Conversion | Dependencies |
|---|---|---|
@turf/line-to-polygon | LineString → Polygon | Validates closure |
@turf/polygon-to-line | Polygon → LineString | Extracts rings |
@turf/bezier-spline | LineString → Smooth curve | Cubic Bézier interpolation |
@turf/polygon-smooth | Polygon → Smoothed polygon | Chaikin's algorithm |
Category Usage Patterns
Typical Module Combination Patterns
The following patterns represent common workflows that combine modules from multiple categories:
Pattern 1: Spatial Join Analysis
@turf/hex-grid(Grid Generation) → Create analysis grid@turf/collect(Data Manipulation) → Aggregate point data into hexagons@turf/center-mean(Clustering) → Find center of each hex@turf/buffer(Transformation) → Create zones around centers
Pattern 2: Route Analysis
@turf/length(Measurement) → Calculate total route length@turf/line-chunk(Geometric Operations) → Split into equal segments@turf/along(Measurement) → Find points at regular intervals@turf/buffer(Transformation) → Create corridor around route
Pattern 3: Contour Mapping
@turf/point-grid(Grid Generation) → Create sample grid@turf/interpolate(Clustering) → Estimate values at grid points@turf/isolines(Clustering) → Generate contour lines@turf/simplify(Transformation) → Reduce contour complexity