Atlaslog
Atlaslog / Turf.js / Tutorial / Spatial analysis fundamentals
Turf.js · Tutorial

Spatial analysis fundamentals

Quick answer

This tutorial introduces Turf.js as a pure computation library: geometry in, geometry or numbers out, usable in browsers and Node. It covers the turf.point, lineString, polygon and featureCollection constructors, the [lng, lat] convention, and the unit rules where distance defaults to kilometers while area is always square meters. You will be able to run your first measurement and sanity-check the result.

Last verified 2026-11-03 · Turf.js 7.x · Cite this page
Key points
Example
<script src="https://cdn.jsdelivr.net/npm/@turf/turf@7/turf.min.js"></script>
<script>
  var a = turf.point([116.391263, 39.907359]);   // 天安门
  var b = turf.point([121.473701, 31.230416]);   // 上海人民广场

  var km = turf.distance(a, b, { units: 'kilometers' });
  console.log(km);   // 1067 左右,单位为公里
</script>
var geom = { type: 'Point', coordinates: [116.391263, 39.907359] };
var feat = turf.feature(geom, { name: '天安门' });

console.log(feat.properties.name);   // 天安门
Notes
Runnable examplesChinese originalAll Tutorials
English edition written for Atlaslog. Code is taken from the original Chinese page and runs unchanged.
Cite this page

Atlaslog (2026). Spatial analysis fundamentals. https://www.jingweizhi.com/en/turf/tutorials/basics.html (accessed 2026-11-03).