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" src="../../js/turf-2.0.0/turf.min.js"></script> </head>
Preparing an example
Before jumping into the implementation of different spatial operations, we need to tweak our example a little bit. First, as...