Polygons to points for heatmap

If I have a bunch of polygons defined by x and y contours and I want to generate a hexbin heatmap to represent the locations of overlap, can I use datashader to get the gridded points at some specified resolution contained by the polygons so I can feed that into hv.hexbin?

e.g.:

polyA =  {'x': [0, 1,  2, -1, 0,], 'y' [0,0,2,4,0]}
polyB = {'x': [-0.5, 1.5, 1.5, -0.5], 'y': [3, 3, 4, 3]})
polys = [polyA, polyB]

poly_points = some_datashader_func(polys, resolution=(.1,.1)

hv.Hexbin(poly_points)

I determined that this probably not the right approach for my use case and will try to utilize Datashader to just rasterize the polygons directly and see how far I can get with that

Why hexbin rather than Cartesian heatmap? You should be able to rasterize the two shapes into the same Canvas in Datashader (directly, not via holoviews) and use xarray to count matching pixels. Also see xarray-spatial.

Right, see my comment above.

The original thought was that I might have hundreds of overlapping polygons in a small area, in which case showing the actual contours becomes much less useful, compared to just communicating general density and maintaining easy interactivity with a region that one might want to encircle with a lasso tool.

But yes, Philipp and I determined that I should at least just start with Datashader and see how far we can get…