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

A cutoff distance in spatial interpolators? #1431

Open
Fil opened this issue Apr 6, 2023 · 3 comments
Open

A cutoff distance in spatial interpolators? #1431

Fil opened this issue Apr 6, 2023 · 3 comments
Assignees
Labels
enhancement New feature or request geo Maps and projections

Comments

@Fil
Copy link
Contributor

Fil commented Apr 6, 2023

When the sample data covers only a subdomain of the frame (say, land), it is sometimes desirable to avoid extending it too much into lakes and oceans. A solution is to add a cutoff distance (in "raster" pixels, like the blur option).

Left: random walk; right: random walk with a cutoff at 9px (and pixelSize: 0.5).

cutoff

This can be done in user space with custom interpolators, but seems like a simple option to offer in interpolatorNearest (which would deprecate interpolateNearest), and interpolatorRandomWalk. (I haven't looked at interpolatorBarycentric yet.)

Code patch (to be optimized to avoid Math.hypot and skip unless cutoff is specified):

- W[k] = V[index[ix]];
+ W[k] = Math.hypot(X[index[ix]] - x, Y[index[ix]] - y) <= cutoff ? V[index[ix]] : NaN;

Feature suggested by @HarryStevens

(Slightly related to a generic “clip” feature #1109 —but here we only have point samples, no geojson.)

@Fil Fil added enhancement New feature or request geo Maps and projections labels Apr 6, 2023
@Fil Fil self-assigned this Apr 6, 2023
@Fil
Copy link
Contributor Author

Fil commented Nov 27, 2023

In interpolatorBarycentric we might want to interpolate only the inside of triangles where the longest edge is small enough.

@mbostock
Copy link
Member

This would be useful in the binned GAIA stars raster plot.

@Fil
Copy link
Contributor Author

Fil commented Nov 13, 2024

Here's an alternative, which might be more useful
https://observablehq.observablehq.cloud/pangea/plot/interpolate-flood

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

No branches or pull requests

2 participants