Turf.js

一个用JavaScript编写的模块化地理空间引擎。「A modular geospatial engine written in JavaScript」

Github星跟踪图

turf

Version Badge
Travis CI
Gitter chat
Backers on Open Collective
Sponsors on Open Collective Coverage Status
Greenkeeper badge

A modular geospatial engine written in JavaScript

turfjs.org


Turf is a JavaScript library for spatial analysis. It includes traditional spatial operations, helper functions for creating GeoJSON data, and data classification and statistics tools. Turf can be added to your website as a client-side plugin, or you can run Turf server-side with Node.js (see below).

Installation

In Node.js

npm install @turf/turf

In browser

Download the minified file, and include it in a script tag. This will expose a global variable named turf.

<script src="turf.min.js" charset="utf-8"></script>

You can also include it directly from a CDN:

<script src="https://cdn.jsdelivr.net/npm/@turf/turf@5/turf.min.js"></script>

You can create light-weight turf builds with only the functions you need using the turfjs-builder UI or using browserify as described below.

Browserify

All of Turf's functions can also be installed as separate modules. This works well with tools like browserify where you want to install only the code you need. It also allows you to mix and match modules. This is the recommended usage pattern for most production environments. For example, to install the point and buffer modules use:

npm install @turf/helpers @turf/buffer

Bower [NOTE: Bower support has been dropped Jan 1st 2017]

Not recommended. Please don't use Bower. Use Browserify, Webpack, or the CDN instead.

TypeScript

TypeScript is supported internally within each module, no installs required.

Other languages

Ports of Turf.js are available in:

Turf for Swift is experimental and its public API is subject to change. Please use with care.


Data in Turf

Turf uses GeoJSON for all geographic data. Turf expects the data to be standard WGS84 longitude, latitude coordinates. Check out geojson.io for a tool to easily create this data.

NOTE: Turf expects data in (longitude, latitude) order per the GeoJSON standard.

Most Turf functions work with GeoJSON features. These are pieces of data that represent a collection of properties (ie: population, elevation, zipcode, etc.) along with a geometry. GeoJSON has several geometry types such as:

  • Point
  • LineString
  • Polygon

Turf provides a few geometry functions of its own. These are nothing more than simple (and optional) wrappers that output plain old GeoJSON. For example, these two methods of creating a point are functionally equivalent:

// Note order: longitude, latitude.
var point1 = turf.point([-73.988214, 40.749128]);

var point2 = {
  type: 'Feature',
  geometry: {
    type: 'Point',
    // Note order: longitude, latitude.
    coordinates: [-73.988214, 40.749128]
  },
  properties: {}
};

Contributors

This project exists thanks to all the people who contribute. [Contribute].

Backers

Thank you to all our backers! ? [Become a backer]

Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]










主要指标

概览
名称与所有者Turfjs/turf
主编程语言TypeScript
编程语言JavaScript (语言数: 3)
平台Linux, Mac, Web browsers, Windows
许可证MIT License
所有者活动
创建于2013-10-03 14:50:25
推送于2025-07-19 17:09:21
最后一次提交2025-05-25 13:58:18
发布数98
最新版本名称v7.2.0 (发布于 2024-12-28 15:28:14)
第一版名称1.3.0 (发布于 )
用户参与
星数9.9k
关注者数179
派生数1k
提交数3.8k
已启用问题?
问题数1762
打开的问题数241
拉请求数847
打开的拉请求数45
关闭的拉请求数184
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?