Compare Polygons through Rasterization.
npm install polygon-similarity1 and 0.1 for both bands and divide that1 for at least one of the bands.js
import { compare } from "polygon-similarity";const a = { "type": "Polygon", "coordinates": [[[30,10],[40,40],[20,40],[10,20],[30,10]]] };
const b = { "type": "Polygon", "coordinates": [[[29.93,10.49],[40.44,39.76],[20.39,40.31],[10.45,20.20],[29.93,10.49]]] };
compare(a, b);
{
// modified Jaccard similarity coefficient
"score": 0.9565577847786437,
"counts": {
"0:0": 3969, // both outside
"1:1": 5769, // both inside
"1:0": 179, // only first inside
"0:1": 83 // only second inside
}
}
``