Turfjs/turf

Name: turf

Owner: turf

Description: A modular geospatial engine written in JavaScript

Created: 2013-10-03 14:50:25.0

Updated: 2018-01-19 23:18:36.0

Pushed: 2018-01-17 21:33:44.0

Homepage: http://turfjs.org/

Size: 31309

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

turf

Version Badge Travis CI Gitter chat 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
install @turf/turf
In browser

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

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

You can also include it directly from a CDN:

ipt 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:

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:


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 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:

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:

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

point2 = {
pe: 'Feature',
ometry: {
type: 'Point',
// Note order: longitude, latitude.
coordinates: [-73.988214, 40.749128]

operties: {}


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.