Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
[WIP] Spherical triangulation and interpolation #182
base: main
Are you sure you want to change the base?
[WIP] Spherical triangulation and interpolation #182
Changes from 8 commits
e40fff5
ef028e4
27a7124
0476e3e
c6da37f
1bcba2c
733faac
6979ce4
5f1c6bb
72c395c
f1ffce7
41a3e2e
893b647
ecd7996
7e83107
937e66f
2f6d4f2
0a7a4e6
afe40f5
37190f7
7a3667e
bd608e7
e638b17
4de0db7
cf3465c
3f36634
6b33e28
46341c1
f8fd202
a63c342
e23c419
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unused. Were there issues? You mentioned an issue with
convert_boundary_points_to_indices
, is it related?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
boundary_faces
is also unusedThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue here was that a lot of faces were connecting to two boundary points and one data point, which is effectively a degenerate face and thus useless.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@asinghvi17
projected_points
is three-dimensional. Theconvex_hull
function is treating it by ignoring thez
coordinate of each point. What is supposed to be the input here? This is the issue you're having with NaturalNeighbours - the triangulation is very invalid.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
projected_points
' z coordinate only carries metadata, so it's fine for it to be three-dimensional. That being said I haven't checked the triangulation in stereographic space, it might have issues there too.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On main the boundary points generate degenerate triangles, I guess I can remove those?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm surprised that it's generating triangles where some of the vertices repeat..
The issue to me just looks like the triangles are somehow calculated incorrectly. In the plot I show at least the triangulation is non-planar
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not entirely unexpected, since the triangulation is computed in stereographic space (where the triangulation generated is planar, correct, etc) and not in the projected space that we are currently in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that would be a problem. Maybe it's best to create some kind of spherical triangulation type, which can also handle spherical Voronoi? That sounds like a lot of effort though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really know how you would get around this issue. It just seems like a bug somewhere to me.. the projection isn't an isometry but it should be conformal, right? I think conformal maps would show up better than what we see in the image above, e.g. it should preserve angles. The crossings seem to come only from boundary vertices (from a visual check anyway, who knows about the interior) which suggests you're missing something when handling only the interior triangles.
If everything is fine and there are in fact no bugs in the actual creation and my thinking is incorrect, it would be interesting to know how the other library handles this. Maybe there are things I need to do on DelaunayTriangulation's side to help
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, to clarify - the triangulation is done in stereographic space, where the triangulation would be completely valid. I'm trying to interpolate in the Bertin 1953 projection, which doesn't have the same conformal property as the stereographic projection. I guess what I was trying to do is actually the incorrect thing, and I should be figuring out how to interpolate on the sphere instead...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see.. my thinking was that you can do everything on the valid triangulation and then lift it back up to the sphere. I'll probably have to look more at the algorithm itself to understand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At least for interpolation, I would expect that to have issues when getting the values of points near the chosen pivot point in spherical space - there's always a point which wouldn't be connected to the triangulation in stereographic space, and neighbours in spherical space would be separated by almost the entire domain of points.
The first problem could be solved by injecting a rectangular boundary, but I'm not really sure how to deal with the second problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you need
bertin_boundary_poly
for? Are you just using it to see if a point is inside the triangulation? You could look atDelaunayTriangulation.dist(tri, q)
I thinkThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was trying to see if I could filter out points that are outside the convex hull and therefore not within any triangle of
tri
, but no luck with that.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What goes wrong here? Can you just do something like
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's... concerning. That should be impossible since it should be finding it in a ghost triangle at the very least... will take a look and actually run the code later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think one problem is that the mesh and convex hull here don't actually cover the full Earth - see
mesh(bertin_points, faces)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see https://proj.org/en/9.4/operations/projections/bertin1953.html or https://observablehq.com/@fil/spherical-contours?collection=@fil/voronoi for comparison
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there issues even when using
Sibson(1)
below? Or what's the miseryThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I'm not quite sure what the issue is here, in the worst case I can always sample in stereographic space but that seems pretty bad...