Turf.js API Documentation

website·Indexed 36 days ago

https://turfjs.org

A geospatial analysis library for GeoJSON. Provides a comprehensive set of modules for spatial operations, including geometry creation, boolean checks, and coordinate iteration. Documentation covers version 7.4.0 and the 'Next' version, featuring APIs such as union, dissolve, lineReduce, and nearestNeighborAnalysis.

Tokens
432.5K
Snippets
2.7K
Records
3.7K
Agent score
61%

What's inside Turf

  1. Overview of Turf.js

    Turf is a modular JavaScript library for spatial analysis. It provides traditional spatial operations, helper functions for creating GeoJSON data, and tools for data classification and statistics. It can be used as a client-side plugin for websites or run server-side using Node.js.
    npm install @turf/turf
  2. Overview of Turf.js

    Turf is a modular JavaScript library for spatial analysis. It provides traditional spatial operations, helper functions for creating GeoJSON data, and tools for data classification and statistics. It can be used as a client-side plugin for websites or run server-side using Node.js.
    npm install @turf/turf
  3. Overview of Turf.js

    Turf is a modular geospatial engine written in JavaScript used for spatial analysis. It provides traditional spatial operations, helper functions for creating GeoJSON data, and tools for data classification and statistics. Turf can be integrated as a client-side plugin for websites or run server-side using Node.js.
    # Install Turf for Node.js
    npm install @turf/turf
  4. Overview of Turf.js geospatial engine

    Turf is a modular JavaScript library for spatial analysis. It provides traditional spatial operations, helper functions for creating GeoJSON data, and tools for data classification and statistics. It can be used as a client-side plugin for websites or run server-side using Node.js.
  5. Overview of Turf.js geospatial engine

    Turf is a JavaScript library for spatial analysis. It provides a modular geospatial engine that includes traditional spatial operations, helper functions for creating GeoJSON data, and tools for data classification and statistics. It can be used as a client-side plugin for websites or run server-side using Node.js.
  6. Overview of Turf.js geospatial engine

    Turf is a modular JavaScript library for spatial analysis. It provides traditional spatial operations, helper functions for creating GeoJSON data, and tools for data classification and statistics. It can be used as a client-side plugin for websites or run server-side using Node.js.
  7. Overview of Turf.js geospatial library

    Turf.js is a collection of modular, simple-to-understand JavaScript functions designed to work with GeoJSON data. Because it runs entirely on the client side, it does not require sending data to a server, ensuring faster processing and better privacy.
  8. Overview of Turf.js geospatial engine

    Turf is a modular JavaScript library for spatial analysis. It provides tools for traditional spatial operations, helper functions for creating GeoJSON data, and tools for data classification and statistics. It can be used as a client-side plugin for websites or run server-side using Node.js.
  9. Calculate the median center of a point set using @turf/center-median

    The centerMedian function takes a GeoJSON FeatureCollection of points and iteratively calculates the median center. The median center is defined as the point that requires the least total travel from all other points in the dataset. It is less sensitive to outliers than @turf/center-mean but is attracted to clustered data. It supports weighting based on a feature property.
  10. Validate GeoJSON object types using geojsonType

    The geojsonType function is used to enforce expectations about the types of GeoJSON objects passed into Turf functions. It ensures that the provided GeoJSON object matches the required type for a specific operation.
    import { geojsonType } from "@turf/invariant";
    
    // Example usage
    geojsonType(value, type, name);
  11. Validate FeatureCollection types using collectionOf

    The collectionOf function is used to enforce expectations about the types of features within a FeatureCollection input for Turf.js. It internally utilizes geojsonType to verify that the geometry types within the collection match the expected type.
    import { collectionOf } from "@turf/invariant";
    
    // Example usage
    const result = collectionOf(featureCollection, expectedType, functionName);
  12. Validate GeoJSON Feature types using featureOf

    The featureOf function is used to enforce expectations about the types of GeoJSON Feature inputs. It internally utilizes geojsonType to verify if the provided feature matches the expected geometry type. If the validation fails, it typically throws an error to ensure the calling function receives the correct data structure.
    import { featureOf } from "@turf/invariant";
    
    // Example: Ensure a feature is a Point
    featureOf(myFeature, "Point", "myFunctionName");