observablehq / plot

A concise API for exploratory data visualization implementing a layered grammar of graphics
https://observablehq.com/plot/
ISC License
4.16k stars 171 forks source link

fix centroid/geocentroid with tips #2086

Closed Fil closed 1 month ago

Fil commented 1 month ago

closes #2085

cc: @jwoLondon (and can you give us provenance information for the dataset?)

An imperfection is that x and y show up in the tip in the londonCarAccessGeoCentroid example.

jwoLondon commented 1 month ago

I derived the car access data from the UK Census (all covered by Open Government Licence v3.0. Specifically the local authority level spatial aggregations for:

(proportions calculated by me by comparing with total households available in the same tables).

Spatial London borough data derived from https://geoportal.statistics.gov.uk/datasets/caaf81b26a45453fa4849dbce31a3293_0/explore by selecting, simplifying and reprojecting in MapShaper.

Fil commented 1 month ago

This is ready to review.

mbostock commented 1 month ago

A related question is should the tip option work directly with the geo mark (without requiring the geoCentroid transform explicitly)? It sure seems like that would be convenient. But using centroids for pointing at polygons maybe isn’t great, so I wonder if that’s an acceptable implementation, or if we should be thinking about other pointing mechanisms (e.g., SDF).

Fil commented 1 month ago

(tracking the secondary issue of default tips in https://github.com/observablehq/plot/issues/2087)

mbostock commented 1 month ago

I’ve made a sketch at my alternate take in #2088. I think it could be further extended (for example maybe there’s an option to use the geoCentroid transform instead of the centroid transform, or maybe there’s an option to tell the pointer transform to use the nearest polygon instead of the nearest centroid — though in that case, we’d still need to pick an xy point to place the tip) but maybe it’s an acceptable interim solution.

Fil commented 1 month ago

superseded by #2088