Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add default tips for the geo mark #2087

Closed
Fil opened this issue Jun 14, 2024 · 2 comments · Fixed by #2088
Closed

Add default tips for the geo mark #2087

Fil opened this issue Jun 14, 2024 · 2 comments · Fixed by #2088
Assignees
Labels
enhancement New feature or request

Comments

@Fil
Copy link
Contributor

Fil commented Jun 14, 2024

If the geo mark has no x and y channels, it would be nice if the tip option worked. It could create x and y with a centroid initializer. However, a system that tracks the closest geometry, relying on distance to the shape rather than to its centroid, would arguably be better. The difference in strategy is striking if you consider France, whose centroid is in the Atlantic, because Guyane. But centroids show the small features better.

(Note: this is a duplicate of #1743)

@Fil Fil added the enhancement New feature or request label Jun 14, 2024
@Fil Fil self-assigned this Jun 14, 2024
@jwoLondon
Copy link

Don't know how expensive SDF or similar would be comparison to centroid calculations, but if it is too costly, in my experience taking the centroid of the largest polygon in a multi polygon almost always captures a representative centre point.

The more problematic cases can be heavily concave features (e.g. a 'C' shape mostly surrounding a different convex polygon). There a midpoint from some kind of skeletonisation might be more meaningful, but won't be cheap.

@Fil
Copy link
Contributor Author

Fil commented Jun 15, 2024

The best solution IMO would be to use the “pole of inaccessibility” transform (discussed in #1587 — which I had failed to mention yesterday), as implemented in mapbox/polylabel. This could be the default for #2088 — it is a pragmatic approach that would make interactive tips behave nicely in general (and could also result in better placement for labels).

More speculatively, I also want to suggest a new geo option value for Plot.pointer (besides x, y and xy), which would point to the closest geometry. The way I would do this:

  1. draw the shapes on a relatively coarse canvas and read the active pixels back (like https://observablehq.com/@fil/another-hex-map#geoContainsCache but for an array of geometries).
  2. add the poles of inaccessibility of each geometry, to make sure each one has at least 1 active point.
  3. on pointer move, do a closest point search in that point list (e.g. with a quadtree search) and return the corresponding index.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants