Comparing version 0.0.117 to 0.0.118
@@ -14,6 +14,4 @@ //https://github.com/jasondavies/conrec.js | ||
t.square = require('./square') | ||
t.donuts = require('./donuts') | ||
t.merge = require('./merge') | ||
module.exports = function(points, z, resolution, breaks, donuts, done){ | ||
module.exports = function(points, z, resolution, breaks, done){ | ||
t.tin(points, z, function(err, tinResult){ | ||
@@ -20,0 +18,0 @@ t.extent(points, function(err, bbox){ |
{ | ||
"name": "turf", | ||
"version": "0.0.117", | ||
"version": "0.0.118", | ||
"description": "a node.js library for performing geospatial operations with geojson", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -66,2 +66,3 @@ turf | ||
- [contour](#contour) | ||
- [isolines](#isolines) | ||
@@ -641,2 +642,21 @@ ####classification | ||
###contour | ||
Takes a FeatureCollection of points with z values and an array of value breaks and generates contour polygons. This is a great way to visualize interpolated density on a map. It is often used for elevation maps, weather maps, and isocrones. The main advantage over a heat map is that contours allow you to see definitive value boundaries, and the polygons can be used to aggregate data. For example, you could get the 5000 ft elevation contour of a mountain and the 10000 ft elevation contour, then aggregate the number of trees in each to see how elevation affects tree survival. | ||
```javascript | ||
var t = require('turf') | ||
var z = 'elevation' | ||
var resolution = 15 | ||
var breaks = [.1, 22, 45, 55, 65, 85, 95, 105, 120, 180] | ||
t.load('../path/to/points.geojson', function(err, points){ | ||
t.isolines(points, z, resolution, breaks, function(err, contours){ | ||
if(err) throw err | ||
console.log(contours) | ||
}) | ||
}) | ||
``` | ||
###sample | ||
@@ -643,0 +663,0 @@ |
@@ -6,5 +6,5 @@ var t = require('../index'), | ||
describe('isolines', function(){ | ||
it('should take a set of points with z values and output a set of contour polygons', function(done){ | ||
it('should take a set of points with z values and output a set of contour lines', function(done){ | ||
t.load(__dirname+'/testIn/elevation1.geojson', function(err, points){ | ||
t.contour(points, 'elevation', 15, [25, 45, 55, 65, 85, 95, 105, 120, 180], false, function(err, contours){ | ||
t.isolines(points, 'elevation', 15, [25, 45, 55, 65, 85, 95, 105, 120, 180], function(err, contours){ | ||
if(err) throw err | ||
@@ -18,7 +18,7 @@ //fs.writeFileSync('./testOut/contours1.geojson', JSON.stringify(contours)) | ||
}) | ||
it('should take a set of points with z values and output a set of contour polygons with jenks breaks', function(done){ | ||
it('should take a set of points with z values and output a set of contour lines with jenks breaks', function(done){ | ||
t.load(__dirname+'/testIn/elevation1.geojson', function(err, points){ | ||
t.jenks(points, 'elevation', 5, function(err, breaks){ | ||
if(err) throw err | ||
t.contour(points, 'elevation', 15, breaks, false, function(err, contours){ | ||
t.isolines(points, 'elevation', 15, breaks, function(err, contours){ | ||
if(err) throw err | ||
@@ -33,5 +33,5 @@ //fs.writeFileSync('./testOut/contours2.geojson', JSON.stringify(contours)) | ||
}) | ||
it('should take a set of points with decimal z values and output a set of contour polygons', function(done){ | ||
it('should take a set of points with decimal z values and output a set of contour lines', function(done){ | ||
t.load(__dirname+'/testIn/elevation2.geojson', function(err, points){ | ||
t.contour(points, 'elevation', 15, [-2000,-20, -5, -1, 0, 2, 5, 10, 20, 30, 500 ], false, function(err, contours){ | ||
t.isolines(points, 'elevation', 15, [-2000,-20, -5, -1, 0, 2, 5, 10, 20, 30, 500 ], function(err, contours){ | ||
if(err) throw err | ||
@@ -45,5 +45,5 @@ //fs.writeFileSync('./testOut/contours3.geojson', JSON.stringify(contours)) | ||
}) | ||
it('should take a set of points with negative z values and output a set of contour polygons', function(done){ | ||
it('should take a set of points with negative z values and output a set of contour lines', function(done){ | ||
t.load(__dirname+'/testIn/elevation3.geojson', function(err, points){ | ||
t.contour(points, 'elevation', 15, [25, 45, 55, 65, 85, 95, 105, 120, 180], false, function(err, contours){ | ||
t.isolines(points, 'elevation', 15, [25, 45, 55, 65, 85, 95, 105, 120, 180], function(err, contours){ | ||
if(err) throw err | ||
@@ -57,5 +57,5 @@ //fs.writeFileSync('./testOut/contours4.geojson', JSON.stringify(contours)) | ||
}) | ||
it('should take a set of points lopsided edges and output a set of contour polygons', function(done){ | ||
it('should take a set of points lopsided edges and output a set of contour lines', function(done){ | ||
t.load(__dirname+'/testIn/openContourPoints.geojson', function(err, points){ | ||
t.contour(points, 'elevation', 15, [5, 15, 40, 80, 90, 110], false, function(err, contours){ | ||
t.isolines(points, 'elevation', 15, [5, 15, 40, 80, 90, 110], function(err, contours){ | ||
if(err) throw err | ||
@@ -69,7 +69,7 @@ //fs.writeFileSync('./testOut/contoursEdges.geojson', JSON.stringify(contours)) | ||
}) | ||
it('should take a set of points with internal valleys and output a set of contour polygons', function(done){ | ||
it('should take a set of points with internal valleys and output a set of contour lines', function(done){ | ||
t.load(__dirname+'/testIn/holeContourPoints.geojson', function(err, points){ | ||
t.isolines(points, 'elevation', 15, [5, 15, 40, 80, 90, 110], true, function(err, contours){ | ||
t.isolines(points, 'elevation', 15, [5, 15, 40, 80, 90, 110], function(err, contours){ | ||
if(err) throw err | ||
fs.writeFileSync(__dirname+'/testOut/isolines.geojson', JSON.stringify(contours)) | ||
//fs.writeFileSync(__dirname+'/testOut/isolines.geojson', JSON.stringify(contours)) | ||
contours.should.be.ok | ||
@@ -76,0 +76,0 @@ contours.features.should.be.ok |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4227210
1146
24388