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.

Incorrectly getting `null` from `turf.intersect`

See original GitHub issue

I’m trying to use turf to generate intersections of some polygons but it randomly seems to not work. For example, the polygons in this gist clearly intersect, but turf.intersect returns null

image

> const turf = require('@turf/turf');
> const data = require('./data.json');
> turf.intersect(data.features[0], data.features[1])
null

https://gist.github.com/dschep/92bc5f308b8506a774ecc9482795ccdf

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
tibettycommented, Aug 28, 2019

The turf.intersect function is just a thin && buggy layer of user-friendly encapsulation of martinez-polygon-clipping, please consider using it directly. I encountered the same issue and got it resolved with that package.

2reactions
rowanwinscommented, Feb 18, 2021

Resolved in v6.3.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

Turf intersect doesn't always work with polygons
TurfJS just fails to calculate intersections with highly-detailed geometries - internally, it will truncate the precision of the geometries' ...
Read more >
Turf JS Intersection issues - Stack Overflow
I am encountering some issues finding if two polygons intersect each other with turfs. What is the purpose of my ...
Read more >
Advanced geospatial analysis - Turf.js
Takes two polygon or multi-polygon geometries and finds their polygonal intersection. If they don't intersect, returns null.
Read more >
Turfjs使用笔记
Turf.js与Polygon,MultiPolygon,GeometryCollection相交的缓冲区:https://www.thinbug.com/q/40211522 2.Incorrectly getting null from turf.intersect ...
Read more >
NULL -Aware Comparison: is [not] distinct from - Modern SQL
In SQL NULL = NULL isn't true. Use IS NOT DISTINCT FROM instead of equals (=) for null-aware comparisons.
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