question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[@turf/concave] Returns a convex hull instead of a concave one

See original GitHub issue

Not sure if it always happen, but here is an example of coordinates for which the hull is not concave. Just to be sure that we talk about the same concave hull, here is what I expect:

My version is @turf/concave@6.0.5 but it seems like the same bug appears on older versions too.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
rowanwinscommented, Jul 17, 2018

Looking at this a bit further we should probably change out our algorithm for concaveman

1reaction
cglacetcommented, Jul 18, 2018

I updated the gist with the comparison Turf vs. Concaveman. The result from Concaveman seems way closer to what I expected in the first place.

Of course this is just one example and it doesn’t prove Concaveman is good, but it’s a start for me.

In case someone needs this too, here is the code I used to test both the Turf and the Concaveman versions (with input.json):

import testPoints from './input.json';
import concaveman from 'concaveman';
import turfConcave from '@turf/concave';
import { polygon as turfPolygon, featureCollection } from '@turf/helpers';

function turfConcaveman(points:FeatureCollection<Point>){
   const coordinates = points.features.map(f => f.geometry.coordinates);
   return turfPolygon([concaveman(coordinates)]);
}

const turf = {
   polygon: turfPolygon,
   featureCollection,
   concaveman: turfConcaveman,
   concave: turfConcave,
};

const polygonCave = turf.concaveman(testPoints);
const polygonTurf = turf.concave(testPoints);
console.log(JSON.stringify(turf.featureCollection([polygonTurf, polygonCave, ...testPoints.features])));
Read more comments on GitHub >

github_iconTop Results From Across the Web

Turf.js | Advanced geospatial analysis
Takes a set of points and returns a concave hull Polygon or MultiPolygon. Internally, this uses turf-tin to generate geometries.
Read more >
Top 5 concaveman Code Examples
To help you get started, we've selected a few concaveman examples, based on popular ways it is used in public projects. Secure your...
Read more >
Topographic Turf examples: pointsWithinPolygon
Click an object to read info. Drag red markers to better location ; pointsWithinPolygon, 0, Find points within a polygon ; nearest_point_online, 1,...
Read more >
How to create a non-intersecting polygon passing through ...
... convexHullCoordinates = this.convexHull(coordinates); let feature = new Feature(new Polygon([convexHullCoordinates])); return feature; }.
Read more >
Licenses
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found