observablehq / observablehq/plot

Multiscale density mark / spatial interpolator?

Open
#2,241 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
HTML
Stars
5.4k
Forks
244
PR merge metrics
No merged PRs in 30d

Description

Image

As pioneered by @jwolondon, it's a sum of the density field at several harmonic bandwidths (1, 2, 4, 8, 16, 32, 64px) weighted by 1, 4, 9, 25, 36, 49.

I did a basic implementation (11 lines of code) as a spatial interpolator that iterates d3.blur2
https://observablehq.com/@fil/multiscale-density-spatial-interpolator.

(It could be seen as a new option for the density mark, or maybe we should subsume the density mark into a spatial interpolator + initializer.)

An advantage of using a spatial interpolator is that we can use it with the raster mark — we don't have to run a contouring algorithm. A disadvantage is that we don't get to set the color scale… but that can be fixed by using an initializer—which would also be necessary to normalize across facets.

There are a few more TODOs, listed in the notebook:

  • to not ignore points outside the raster frame
  • to add a weight option

We might want to scale the bandwidth (the "kilometer" in the original notebook is about 1.5 pixels, but it's complicated because d3.blur2 with a very small radius does not map linearly to the gaussian bandwidth… see https://observablehq.com/@d3/d3-blur for details).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked Observable multiscale-density spatial interpolator and compare it with the existing density mark, spatial interpolator, initializer, and raster mark entry points. The scope is not settled; possible completion includes choosing an API direction and addressing the notebook TODOs for points outside the raster frame and a weight option.

Written by the indexing model from the issue text.

Assessment

Tech stack
d3js
Domain
data-visualization
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.