O'Reilly logo

Mastering OpenLayers 3 by Gábor Farkas

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Spatial analysis with Turf

In the next example, called ch09_turf, we will extend our application's topological capabilities with Turf. Turf is a well-documented, simple, but capable, library for geospatial analysis. All the basic topological functions are in the library along with some more advanced and scarce functions. Turf uses GeoJSON not only as its exchange format but also as its internal format. This enables it to skip the overhead caused by data conversion.

Tip

You can grab the most recent version of Turf from the GitHub repository at https://github.com/Turfjs/turf/releases.

First, we open the HTML file and resolve the dependencies. We have an easy job with Turf as we only have to provide one extra JavaScript file:

<head> […] <script type="text/javascript" ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required