Point density/pixel area

Counting points is easy (see below). Is there a way in which I can calculate point density, e.g. by accessing the area of each pixel from within datashader?

As a workaround I could fix the datashading parameters (x_sampling etc.) and then calculate pixel area based on those parameters but that quickly gets cumbersome e.g. in DynamicMaps.

Two spinoff ideas:

  1. Ideally of course there’d be a named reduction, e.g. count_density.
  2. Even more general, one could make accessible pixel_area and somehow allow chaining that into the reductions.
import numpy as np
import holoviews as hv
from holoviews.operation.datashader import rasterize
import datashader as dsh
e = hv.Points(np.random.randn(1000, 1000))
rasterize(e, aggregator=dsh.count())