Turf.jsBooleans

turf.booleanEqual

What is turf.booleanEqual?

turf.booleanEqual returns true when two geometries of the same type have identical coordinate values. A precision option controls the number of decimal places used for the comparison.

JavaScript
turf.booleanEqual(feature1, feature2, options?) → boolean

Options include:

  • precision — decimal places to compare (default 6)

When would you use turf.booleanEqual?

Use turf.booleanEqual to deduplicate features whose coordinates should match exactly — identifying repeated rows in a geocoder cache, matching database shapes against an imported GeoJSON, or writing snapshot tests that compare produced geometry to an expected fixture.

Because it checks coordinates at a fixed precision, small floating-point artefacts from coordinate projection do not cause false negatives at the default six-decimal precision (about 10 cm on the earth).

JavaScript
turf.booleanEqual(a, b, { precision: 4 });

FAQs

How do I install Turf.js to use this function?

Install npm install @turf/boolean-equal and import import { booleanEqual } from '@turf/boolean-equal', or use turf.booleanEqual on @turf/turf.

Does it handle reordered rings as equal?

No. Rings with the same vertices but a different starting point or winding order are reported as not equal. Normalise with turf.rewind and align start indices first if you need topological equality.

Does it compare properties too?

No — only the geometry. Properties are ignored. Compare properties manually if you need a full Feature equality check.

When should I tighten or loosen precision?

Tighten (higher precision) when you are comparing authoritative data that should match exactly. Loosen (lower precision) when round-tripping through projections or serialisation might introduce rounding noise.