Please provide the following when reporting an issue:
Problem
Version: 7.2.0
pointToPolygonDistance
When using the method pointToPolygonDistance I get an error that says coordinates must contain numbers. It definitely has something to do with the redundant points at the end of the polygon. (Look at the last 2 entries of the polygon in the GeoJSON section below, they are equal). If I remove one of them, the method works.
When debugging, I see that it is failing because coordinates seems to be NaN:

Code:
// point & polygon can be used from GeoJSON below
const distance = turf.pointToPolygonDistance(point, polygon, {
units: "meters",
});
Stacktrace:
at point (../node_modules/@turf/helpers/index.ts:269:11)
at ../node_modules/@turf/nearest-point-on-line/index.ts:113:25
at ../node_modules/@turf/meta/index.js:748:11
at geomEach (../node_modules/@turf/meta/index.js:597:13)
at flattenEach (../node_modules/@turf/meta/index.js:739:3)
at nearestPointOnLine (../node_modules/@turf/nearest-point-on-line/index.ts:70:3)
at distanceToSegment (../node_modules/@turf/point-to-line-distance/index.ts:113:3)
at ../node_modules/@turf/point-to-line-distance/index.ts:78:15
at ../node_modules/@turf/meta/index.js:941:13
at coordEach (../node_modules/@turf/meta/index.js:119:15)
at ../node_modules/@turf/meta/index.js:913:7
at ../node_modules/@turf/meta/index.js:748:11
at geomEach (../node_modules/@turf/meta/index.js:597:13)
at flattenEach (../node_modules/@turf/meta/index.js:739:3)
at segmentEach (../node_modules/@turf/meta/index.js:898:3)
at pointToLineDistance (../node_modules/@turf/point-to-line-distance/index.ts:73:3)
at ../node_modules/@turf/point-to-polygon-distance/index.ts:80:7
at ../node_modules/@turf/meta/index.js:748:11
at geomEach (../node_modules/@turf/meta/index.js:597:13)
at flattenEach (../node_modules/@turf/meta/index.js:739:3)
at Object.pointToPolygonDistance (../node_modules/@turf/point-to-polygon-distance/index.ts:77:3)
at pointToPolygonDistance (turf/turf.service.ts:128:35)
GeoJson:
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"coordinates": [
[
[
9.717640356727232,
48.2907894548215
],
[
9.718316273398985,
48.289925696874604
],
[
9.719571547217955,
48.2903397314326
],
[
9.718884901710142,
48.29126058936186
],
[
9.717640356727232,
48.2907894548215
],
[
9.717640356727232,
48.2907894548215
]
]
],
"type": "Polygon"
}
},
{
"type": "Feature",
"properties": {},
"geometry": {
"coordinates": [
9.73541368510476,
48.28771763952804
],
"type": "Point"
}
}
]
}
Please provide the following when reporting an issue:
.geojson). Simple reproducible examples are preferrable.Problem
Version: 7.2.0
pointToPolygonDistance
When using the method
pointToPolygonDistanceI get an error that sayscoordinates must contain numbers. It definitely has something to do with the redundant points at the end of the polygon. (Look at the last 2 entries of the polygon in the GeoJSON section below, they are equal). If I remove one of them, the method works.When debugging, I see that it is failing because coordinates seems to be

NaN:Code:
Stacktrace:
GeoJson: