Is there a way of clipping a (geographic) Voronoi diagram within Plot to some arbitrary shape? By default it clips to a bounding rectangle. If I set the domain to come arbitrary geo shape, the Voronoi is clipped to its bounding rectangle, not its actual shape. If, for computational reasons, the clipping region had to be convex, that would still be helpful.
I realise can can use d3.delaunay and other JavaScript to create a geoJSON with the clipped Voronoi diagram, but ideally I’d like to be able to do this as a viewing operation within Plot itself.
Making a geometric clipping is a bit of work. Though Sutherland-Hodgman can work with any shape in this case, because the voronoi cells are convex.
However in most cases it’s enough to do svg clipping; you just need to somehow draw the geo shape into a clipPath. Here’s an example with a (very simple) custom render transform: DIY live map of Air quality in the US / Fil | Observable (it’s clipping a contour mark, not a voronoi mark, but this makes no difference: just replace Plot.contour with Plot.voronoi to see).
The SVG clipPath option looks promising for a view-based solution. For now I may stick to clipping at the data level as this forms part of a workflow I have for generating area maps from point sets. For info, I provided a worked example which also acts as a use-case for clipping Voronoi cells as map units: