What Is a Geometric Difference?
The difference operation subtracts one polygon from another. Given two polygons A and B, the result is the area of A that does not overlap with B. It is essentially "A minus B" — like cutting a hole in polygon A using the shape of polygon B.
How to Use the Difference Tool
Provide two GeoJSON polygon inputs. The tool subtracts the second polygon from the first and returns the resulting geometry. If the polygons do not overlap, the first polygon is returned unchanged. If the second polygon completely covers the first, the result is empty.
Common Use Cases
- Removing a restricted zone from a service area polygon
- Cutting water bodies out of a land use polygon
- Creating donut polygons (polygons with holes)
- Subtracting already-completed survey areas from a study region
Related operations: intersection (area shared by both polygons), union (combined area of both polygons).
Try It
Subtract a smaller Times Square rectangle from a larger Midtown polygon. Paste polygon A (Midtown) and polygon B (Times Square block) into the two inputs:
GeoJSON{
"type": "Feature",
"properties": { "name": "Midtown" },
"geometry": {
"type": "Polygon",
"coordinates": [[[-73.99, 40.75], [-73.97, 40.75], [-73.97, 40.77], [-73.99, 40.77], [-73.99, 40.75]]]
}
}Polygon B (Times Square block to subtract):
GeoJSON{
"type": "Feature",
"properties": { "name": "Times Square Block" },
"geometry": {
"type": "Polygon",
"coordinates": [[[-73.988, 40.756], [-73.984, 40.756], [-73.984, 40.760], [-73.988, 40.760], [-73.988, 40.756]]]
}
}The result is the Midtown polygon with a rectangular hole cut out where Times Square sits. On the map, you will see the Midtown area rendered with a gap in the center. This is a Polygon with an interior ring — the exterior ring is the Midtown boundary and the interior ring is the Times Square cutout.
How It Works
The difference tool uses Turf.js (@turf/difference), which delegates to the JSTS polygon clipping library. The algorithm computes the boolean difference by finding all intersection points between the two polygon boundaries, then tracing the edges that belong to polygon A but lie outside polygon B. The result preserves the coordinate precision of the input. Learn more about spatial operations in the GeoJSON specification guide.