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.

found non-noded intersection between LINESTRING

See original GitHub issue

I ran into the following error, when calling turf.intersect(poly, point1)

"found non-noded intersection between LINESTRING ( 180 -84.71338, -179.942499 -84.721443 ) and LINESTRING ( -143.107718 -85.040752, -142.892279 -84.570497 ) [ (-142.96105271343765, -84.720614586011) ]"

A bit of background:

I am using a combination of turf and turf-multipolygon, with the geojson outline at http://openlayers.org/en/v3.8.2/examples/data/geojson/countries.geojson

My code looks something as follows:

features = countryOutlines.features;
for (i=0; i<features.length; i++) {

    if ( features[i].geometry.type === 'MultiPolygon' ) {
        for (j=0; j<features[i].geometry.coordinates.length; j++) {
            poly = turf.polygon(features[i].geometry.coordinates[j]);
            try {
                if (turf.intersect(poly, point1)) {
                    return features[i].properties.name;
                }                             
            } catch (e) {
                console.error(e, features[i].id, j);
            }
        }
     } else {
        poly = turf.polygon(features[i].geometry.coordinates[0]); 

        if (turf.intersect(poly, point1)) {
            return features[i].properties.name;
        }        
     }
}

The issue happens with the entry for Antartica (ATA). Should the intersect function be dealing with situation or is there a function that would ‘correct’ the data for this situation?

BTW I did modify turf-multipolygon for use in browser based JS:

turf.multipolygon = function(coordinates, properties) {
  if (!coordinates) {
    throw new Error('No coordinates passed');
  }
  return {
    "type": "Feature",
    "geometry": {
      "type": "MultiPolygon",
      "coordinates": coordinates
    },
    "properties": properties || {}
  };
};

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:20 (5 by maintainers)

github_iconTop GitHub Comments

7reactions
morganherlockercommented, Jun 1, 2016

the problem was only happening with some strange polygons.

non-noded intersection

The non-noded intersection error is thrown when self-intersecting polygons are detected. These polygons are invalid, since the interiors & exteriors of the hulls are ambiguous.

3reactions
panuhorsmalahticommented, Sep 6, 2017

I’m seeing this relatively often. The cause for me is that the underlying library, JSTS, loses some coordinate accuracy when converting to and back from JSTS’s own format. After this apparently two “identical” coordinates end up being slightly different:

found non-noded intersection between LINESTRING ( 26.354054995086468 60.814164001413886, 26.354071880268343 60.81332589477252 ) and LINESTRING ( 26.354071880274574 60.81332589446338, 26.354054995088205 60.81416400132764 ) [ (26.354056376031796, 60.81409545732238, undefined) ]

I got the error from dissolve. My workaround is to specify a different PrecisionModel from the default one used. I had to fork turf-dissolve and turf-union for this (note the different API for union).

            try {
                featureCollection.features[i] = union([polygon, matchFeature]);
            } catch (error) {
                if (error && error.message && error.message.includes("found non-noded intersection between")) {
                    const precisionModel = new jsts.geom.PrecisionModel(jsts.geom.PrecisionModel.FIXED);
                    const geometryFactory = new jsts.geom.GeometryFactory(precisionModel);
                    featureCollection.features[i] = union([polygon, matchFeature], geometryFactory);
                } else {
                    throw error;
                }
            }
Read more comments on GitHub >

github_iconTop Results From Across the Web

Fixing non-noded intersection problem using PostGIS
Error performing intersection: TopologyException: found non-noded intersection between LINESTRING (571304 310990, 568465 264611) and LINESTRING (568465 ...
Read more >
found non-noded intersection between LINESTRING - Usage ...
Bug report Sometimes when running cell detection (qupath.imagej.detect.cells.WatershedCellDetection) in the parallel tiled mode it will fail ...
Read more >
NetTopology 'found non-noded intersection' Exception when ...
NetTopology 'found non-noded intersection' Exception when determining the difference between two specific geometries. Save this question. Show ...
Read more >
ST_Difference(g1,g2) throws lwgeom_difference: GEOS Error ...
select ST_Intersection( '', '' ); ERROR: XX000: lwgeom_intersection: GEOS Error: TopologyException: found non-noded intersection between LINESTRING (303308 ...
Read more >
Re: [JPP-Devel] How to avoid non-noded intersection error in ...
However, I get still a similar error found non-noded intersection between LINESTRING ( 130.83397613647227 -0.012151767294376153, ...
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