block by fil ccd7c00f6ee97f388503c7ebaae07384

Extract a band from a Contour Plot [UNLISTED]

Full Screen

Contour plots generated by d3-contour overlay shapes (Multipolygons) of increasing value. To obtain the shape that is between two values a < b, we need to substract the shape B = contour(b) from the shape A = contour(a).

The substraction algorithm for this case is then much simpler than a generic Multipolygon intersection/substraction:

For each polygon in multipolygon B, take a point from its outer ring. Then find the polygon of A that contains this point, and add that ring as a hole (which implies a reversal of its coordinates). Plus, add holes of B as polygons to A.

But I’m not sure this covers all cases, that is, what happens when a hole of A is inside a hole of B?

A simpler method works OK if one wants to extract 1 band (, but it is useless if you need to extract several contiguous bands, as it does not give an exact boundary (there are gaps and overlaps, cf

Forked from mbostock‘s block: Contour Plot