Feature: Snyder Polyhedral Equal Area projections#4758
Conversation
|
@felixpalmer Lots of cool stuff here :) Thank you for this! As discussed in #4389 (comment) , I was also planning to propose a replacement for the current ISEA projection based on a generalized ISEA / RTEA / IVEA method, using a closed-form inverse solution, and address some issues with the current set of parameters. You've taken that a step further with support for different polyhedron nets (and multiple unfolding setups too!!) which is also very cool. Is this using Snyder's original equations, which did not have a closed-form inverse, or the Slice and Dice approach with closed form inverse? We should discuss :) I was also going to test some further improvements suggested by @brsr which could potentially fully remove the need for Slerp in the inverse.
That is quite impressive. Was that tested throughout the globe surface or only for some specific test points? |
|
@jerstlouis the equations are from A5, DGGAL and BRSR, as noted in the header. I didn't reference Slice & Dice for the code, but it is possible that the 3 sources did. I'm open to improvements to the code and equations (e.g. removing the The roundtrip error is just based on a static set of points, you're right that perhaps it is worse if this is expanded across the globe |
|
@felixpalmer In particular, to replace the current
EDIT: It seems that you already support this with Would specifying the rhombic triacontahedron solid naturally yield the RTEA projection (as in DGGAL, https://www.mdpi.com/2220-9964/9/5/315, and https://www.tandfonline.com/doi/full/10.1080/17538947.2022.2130459?utm_source=researchgate.net&utm_medium=article ? I see the special names of Hexakis icosahedron and Decakis dodecahedron that you give to the disdyakis triacontahedron, but based on Snyder's paper specifically, the center of the faces is what is used for tracing the great circles, so the names of the solids would be the Dodecahedron and the Icosahedron (as per the DSEA and ISEA acronyms), right? And for Rhombic Triacontahedron that also naturally yields RT(S)EA. It's a very nice feature to be able to unfold them onto the different nets. Would this unfolding also work on polyhedrons without icosahedral symmetry? The unfolding net needs to have same symmetry as the projection solid? |
|
@jerstlouis could we continue the ISEA discussion here? I've given you access, feel free to update the constants - you understand them better than me. As you say it is already supported by the code.
I believe so, the code is designed to be a generic spherical-planar triangle mapper so you would just need to generate the relevant config files. The ISEA PR is a good example of what is required to add a new projection & polyhedron
Yes I thought a lot about the naming. I settled on this approach as the name tells us which vertex to use as the apex and how many triangles to cut the face into. See the docs for details For brevity (and following the example set by
Yes, this PR literally implements |
Yes, but technically these all refer to the same polyhedron, and I wonder if there couldn't be a more explicitly way to describe it, especially if we consider the possibility to specify the polyhedron and the choice of radiating vertex as projection parameters. For the RTEA configuration, would the name specifying that great circle setup mapping for the d120 be kisrhombic triacontahedron ? Also of course I'm very curious whether this modularity would help test the Archmidean solids configuration like the Truncated Icosahedron (TISEA / TIVEA), and still map that to the icosahedral net and the 5x6 space :) |
I think it should be tetrakis (rhombic) triacontahedron - so a triacontahedron with each face cut into 4 It is true that these all have the same vertices, but by naming them this way you can avoid the whole "radiating vertex" concept as the apex is always in the center of the base polyhedron face (the tip of the kis pyramid) |
|
@felixpalmer Thanks, I am starting to understand how these *kis prefixes work :) tetrakis rhombic triacontahedron makes sense, kis pyramids with 4 faces on each of the 30 faces of the rhombic triacontahedron. kisrhombic triacontahedron is one of the name of the d120 mentioned on https://en.wikipedia.org/wiki/Disdyakis_triacontahedron and likely just a shorthand for that longer name. And apparently "disdya" means twice two-fold (also 4), so disdyakis triacontahedron, tetrakis rhombic triacontahedron, kisrhombic triacontahedron would all naturally mean the RT(S)EA setup. |
|
Converted to draft PR to safe-guard against a premature merge. There's a lot going on in this PR request. This looks impressive but from my very superficial first glance it seems as if there's reimplementations of already existing functionality. In particular, my spidey sense is triggered by |
|
@kbevers The authalic conversion stuff is something that I pointed out before in the codebase was already duplicated in multiple places, and which would be nice to re-use throughout (in multiple other projections). Also the version in this PR in the current stage I think is not taking into consideration the selected ellipsoid's flattening which it ideally should... trying to work with @felixpalmer on improving a few things. |
|
As noted in the changelist, the render scripts are purely to help reviewers recreate the images. The authalic conversion @jerstlouis already pointed out is likely implemented in a number of places in the codebase and I agree we should be leveraging the existing code. I would love to reduce the amount of code added, I'm aware that it is a lot, @jerstlouis is interested in collaborating on this |
|
@jerstlouis @kbevers I've removed the |
Perhaps as a first step we could go back to splitting that more general code for a specific triangle into the common shared (actually I think it is still split in the last version, but inside |
|
Would it be possible to update the PROJ scripts to be able to optionally show that red dot where the default projected 0,0 happens to be? The previous images with the red dot were a very significant improvement showing where that happens to be compared to the previous version (and the images currently in this PR after the recent change). Not having this clearly illustrated is a major pain point in trying to use these projections. |
I don't think the meta operation necessarily results in right triangles? (though for the trigonometric formulation, the math is different as it cannot assume one angle is 90 degrees). Wondering if you made the optimization yet where actually for the typical unfolding the full meta operation is not necessary (you only need it if the net explicitly unfolds the two different parts of the fanned triangles from face center to face vertices into a specially cut-out net -- just the kis operation is otherwise enough). The future custom nets would allow that, but none of the the current hardcoded configurations need that I think (only 12 projection triangles rather than 24 are necessary for the tetrahedron, and only 60 rather than 120 are needed for the dodecahedron and icosahedron) |
|
@brsr thanks for the input and your great work this PR has built on. Long-term agree the partitioning code should be sharable with @jerstlouis red-dot: agree it's useful UX, but it's a
If the face is a regular polygon it does. You're right that this won't work for RTEA but let's deal with that in the future if we add that projection |
|
@rouault Does #4758 (comment) mean that this PR could potentially be considered for 9.9.0? Thanks! |
|
I'm +0 on this PR, meaning it looks OK to be merged, but without understanding of the domain. @kbevers ? |
|
I want to review this PR. Unfortunately I didn't have time until now (looking at the size of it is not helping). About identifying the faces, I had the idea to use a false norting or easting as a prefix per face, as done in EPSG:5649, EPSG:4647 and EPSG:5650 to identify the UTM zone. But it can (must) be done in a later PR. |
|
Thank you @jjimenezshaw ! Regarding the face identification, my preference would be to stick to the numbers used in Figure 4 of Snyder's original 1992 paper -- at least for the polyhedra that are present there (the dodecahedron, icosahedron and truncated icosahedron), and we can extend this to other nets based on the left-to-right, top-to-bottom simple increasing integers. This PR is indeed incredibly useful:
Please note that I also did carefully review this PR, and it is directly related to our on-going paper clarifying and explaining these icosahedral projections together with @ldesousa @mpadillaruiz @brsr and @felixpalmer . The size of the PR is because it is a rewrite / generalization of these polyhedral projections based on proven implementations in DGGAL/GNOSIS and A5, which are based on additional simplification of Snyder's polyhedral projections described in Slice & Dice, as well as by @brsr, myself and @felixpalmer . Despite this much more general and optimal rewrite, as @felixpalmer pointed out, the total size of the code is still smaller than the current version. |
jjimenezshaw
left a comment
There was a problem hiding this comment.
The PR looks ok to me. I didn't check the mathematical formulas, but as the final outputs make sense, I expect they are right.
About structs without initialization, I prefer initializing them always. Years later some code is not working "randomly" due to some garbage in the memory. Specially differently in debug and release, that is really annoying.
| "q," // urm5 | ||
| "path,lsat," // lsat | ||
| "W,M," // hammer | ||
| "aperture,resolution," // isea |
There was a problem hiding this comment.
will this code fail reading an "old" string?
There was a problem hiding this comment.
As discussed in #4389 (comment), we removed the aperture, resolution and mode parameters, as they have nothing to do with the projection, but with a particular tessellation of the space at some refinement level (and they were not properly documented or tested either).
Besides removing these three parameters, there are a couple other minor breaking changes with the previous strings:
- Since the projection now supports ellipsoids, it defaults to GRS80 like any other projection that does rather than a perfect sphere, so that one needs to explicitly use
+ellps=WGS84 +R_Ato bring back the old behavior, - The meaning of
+lat_0and+lon_0have changed from being the orientation of the icosahedron (which is now properly renamed+orient_latand+orient_lon) to being the geodetic coordinates of the+x_0and+y_0projected point (0,0 by default).
When selecting a spherical ellipsoid (e.g., +ellps=WGS84 +R_A), we have kept the default values for what is now+orient_lat and +orient_lon for backward compatibility. Otherwise, the default +orient_lon is shifted 0.05 degrees West (+orient_lon=11.2 instead of 11.25 E) by default for ISEA to avoid a vertex of the icosahedron falling on land when taking the ellipsoid into consideration (this avoids pentagonal zones on land in hexagonal tessellations at the finer levels).
The +azi parameter is now also properly supported by the inverse.
So:
- If an "old" string uses any of
aperture,resolutionormode(other thanplane) -- yes it won't work anymore, - If an "old" string does not already explicitly specify a spherical ellipsoid/radius -- the projection will be very slightly different, taking the GRS80 ellipsoid into account and with the icosahedron orientation shifted by 0.05 degrees West.
- If an "old" string uses
+lat_0or+lon_0-- the result will be very different as the meaning of those parameters changed completely
|
As Javier I've been put of by the size of this PR and have also had other more important (to me) things to do. I'll try to find some time early next week. |
|
Overall I think the work in this PR is solid although I do have some hesitation based on the complexity of the pull request. Especially as it's from a new contributor. Nothing personal, I have no reason to believe the work isn't good but I don't know what to expect regarding maintenance of this code in the long term. I am in favour of @brsr's suggestion:
In particular, I am missing the generalized projection mentioned in 1. Having a general |
|
@kbevers Thank you for the review.
Aside from the fact that @felixpalmer will likely be around to help maintain this code, as the last contributor to this ISEA projection (adding the inverse support), I support this PR as the way forward, and also commit at the very least to provide guidance and clarify anything to anyone wishing to work on it.
This is more or less already implemented with the first part in
The underlying code of the general polyhedral projection is there and already re-usable from the code, with the TSEA, ISEA and DSEA projections very simple (the PROJ_HEAD sections in
I would very much like to see it done, so I think the odds are very good. However, if the consensus is that we should make |
|
Thanks for the input
FWIW I have been a maintainer on deck.gl for the last ~5 years and have a personal interest in this projection as it is foundational to a project of mine. Understand your hesitation though, as I'm new here
Looks like this is the missing piece we need to cleanly land this. In terms of the API, I like what @brsr wrote regarding it being a simple projection that just maps between planar & spherical triangles, without any of the complexity of the nets/polyhedrons. Given that we are just considering a single triangle, it feels off though to call this projection
The generic polyhedral projection you propose @jerstlouis feels like something that could later be built on top - valuable, but separate from what @brsr was asking for based on my reading. How does this sound to you @kbevers @brsr @jerstlouis? |
|
@felixpalmer I think that sounds good. I am not familiar enough with the maths here to have useful input, so I hope others chime in if needed. I am good with using |
My reading was more as I commented above the split you already have with I was thinking that exposing But I agree that the
For a global map, it unfortunately could only be expressed in terms of 60 or 120 different ones of these projections for polyhedra with full Icosahedral symetry (Ih) such as the dodecahedron and icosahedron. The |
@kbevers no, as @jerstlouis says the proj string would be enormous and unwieldy as ISEA contains 120 such triangles. What I'm trying to shield the users from is having to input all those values and instead refer to the whole projection including the polyhedrons using shorthands like I will try and land the |
Okay, I have clearly misunderstood how this all works (re my previous math disclaimer). It's probably not super useful to be able to produce a 120th of a full projection using a hypothetical So, discarding the idea of When I go to https://proj.org/en/stable/operations/projections/index.html, I expect to get to the documentation of a specific projection when I click one of the links. I'd like to keep it that way. Probably the path of least resistance is to put |
I wouldn't expose polyhedral.rst at a top level. There might be Sphinx tricks, like using a TOC in the tsea/dsea/isea pages to point to polyhedra.rst. Don't ask me how exactly, I've already forgotten... but I'm pretty sure there's a way. More a potential hint than a requirement. I'm fine with Kristian's suggestion as well |
|
I am open to suggestions for better solutions. This was just what I could come up with in two minutes. Another way could be to make folder for |
|
@rouault perhaps you were thinking of the Adding this allows us to remove the page from |
To be clear, the original Snyder 1992 paper is titled "An Equal-Area Map Projection For Polyhedral Globes", and it is applicable to all Platonic solids, to the truncated icosahedron which is an Archimedean solid, and likely also to other Archimedean solids with full icosahedral symmetry (among others). The approach in this PR is better generalized compared to the original paper. So I do believe there is value in what you proposed, but I think it is different from @brsr 's suggestion which was for a given spherical triangle. Internally, this modularization of the code would already allow to re-use it in other projections utilizing the same math. As I said above, this user-facing separate triangle projection might also have some value for an end-user since the spherical triangle might be up to 1/8th of the globe (though I'm not personally 300% convinced that this would achieve equal-area), or for projecting a small region which fits within one of those 1/120th or 1/60th of the actual ISEA/DSEA projections -- but I also agree it's not essential and not pushing for it either. I understand it might not be desirable to have the separate Then when we add the generalized version we can re-enable it at the top level. To make the general version work we just need:
I was also suggesting that we automatically infer whether the net refers to the triangles resulting from cutting out a fan from center of faces to vertices (the kis operation e.g., 5 triangles for a pentagonal face) vs. an extra split at the middle from the center (the meta operation e.g., 10 triangles for a pentagonal face) based on the number of indices supplied for the net list. e.g., 120 face indices refer to meta triangles, 60 face indices to the kis triangles. On top of that it would be great to have an embedded implementation of a 2D transform matrix so that we can implement the rhombic/icosahedral symmetry 5x6 space without needing I still need to put together a Web version of my demo app for this allowing to visually edit the nets (polyhedral.ec netWindow.ec). |
|
@felixpalmer BTW I still don't think see the star in Were there any shuriken shaped that way? (I can't see any here -- does it work from an aerodynamics perspective?) ... and on an overly geeky note, I just realized there was an inverted tri-force in the Kingdom of Lorule (the opposite world parallel to Hyrule) in The Legend of Zelda: A Link Between Worlds .
Or simply |
That's neat. I think you should open a separate issue for that for further discussion. You've basically already written it:
|
Thanks! Exactly, that's why I said the odds are really good that it will happen earlier ;) That's essentially where I've spent the majority of my own efforts related to this PR ;) I will open a separate issue. |
docs/source/*.rstfor new APIBackground
Please read the updated documentation in
docs/source/operations/projections/polyhedral.rstfirst as well as Snyder's original paper: AN EQUAL-AREA MAP PROJECTION FOR POLYHEDRAL GLOBES (CARTOGRAPHICA Vol 29 No 1 SPRING 1992 pp 10–21)Back-compatibility with existing
iseaGives same results, with comparisons in
test/gie/builtins.gie. I would propose we remove the oldiseacode, replacing with this implementation.Architecture
To define a projection a polyhedron and net must be defined. The simplest example is that of the 4-sided tetrahedron along with the net definitions:
0as the rootThese details are not exposed to the user via the PROJ API, instead they reference them by name, e.g.
+proj=tsea +net=starWhen building the projection, the following process followed:
pj_polyhedral_datastructpj_polyhedral_dataThe design is generic and adding polyhedra/nets is straightforward and doesn't require large code updates
Change list
Example renders
ISEAExample renders
TSEAExample renders
DSEA