Skip to content
forked from Turfjs/turf

A modular geospatial engine written in JavaScript

License

Notifications You must be signed in to change notification settings

chenbo-hhu/turf

This branch is 2903 commits behind Turfjs/turf:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

6df66c6 · Apr 24, 2016
Apr 24, 2016
Feb 27, 2016
Feb 27, 2016
Feb 26, 2016
Feb 27, 2016
Mar 13, 2016
Oct 3, 2013
Feb 29, 2016
Jan 13, 2015
Mar 10, 2016
Jun 12, 2015
Mar 11, 2016
Apr 22, 2016

Repository files navigation

turf

Version Badge Circle CI Gitter chat

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

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 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-point turf-buffer

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.

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:

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

var point1 = turf.point([0, 0]);

var point2 = {
  type: 'Feature',
  geometry: {
    type: 'Point',
    coordinates: [0, 0]
  },
  properties: {}
};

About

A modular geospatial engine written in JavaScript

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%