Turf 是一个 JavaScript 的模块化的 GIS 引擎,它执行地理空间与GeoJSON数据处理任务,可以在服务器或在浏览器上运行。
Node.js 示例代码:
// find all the snakes within 1 mile of a wombat var turf = require('turf'); var fs = require('fs'); var wombats = fs.readFileSync('./wombats.geojson'); var snakes = fs.readFileSync('./snakes.geojson'); var oneMileRing = turf.buffer(wombats, 1, 'miles'); var snakesNearWombats = turf.within(snakes, oneMileRing); console.log(snakesNearWombats);
安装方法:
npm install turf