SciTools / cartopy

Cartopy - a cartographic python library with matplotlib support
https://scitools.org.uk/cartopy/docs/latest
BSD 3-Clause "New" or "Revised" License
1.41k stars 359 forks source link

Pierce quinquennial projection #713

Open jonathf opened 8 years ago

jonathf commented 8 years ago

Do Cartopy have support for Pierce quinquennial projection? I've looked, but wasn't able to find it.

If not, consider this a wish for new feature.

pelson commented 8 years ago

That would be a very neat projection to have. Unfortunately, proj.4 doesn't have such a projection, so we'd be on our own in implementing the transformation. That would also be the first projection in cartopy which doesn't use proj.4, which may have its own challenges.

Mightn't be too hard though, d3.geo does have one: http://bl.ocks.org/mbostock/4310087

jonathf commented 8 years ago

I don't have Cartopy experience speifically, but I know Python and mapping. I can make a pyproj-like function that maps between Peirce quinquennial and WGS84 using the original algorithm from 1879.

If I make this, can someone else implement it into Cartopy?

pelson commented 8 years ago

If I make this, can someone else implement it into Cartopy?

I can definitely give it a go. Basically, it would serve as a prototype for non proj.4 cartopy projections and would be a really interesting first step down that route. Incidentally, cartopy is using proj.4, not the python bindings from pyproj, but that shouldn't make too much difference. Bear in mind, it is important to define both the forward and inverse transformations from Peirce to WGS84 for visualisation purposes.

jonathf commented 8 years ago

Okay.

Quick question:

Much easier to translate then to re-invent the wheel. I found some TCL-code that I should be able to translate just fine. It is part of a package with the following licencing terms: http://bibdigital.sid.inpe.br/col/iconet.com.br/banon/2009/09.04.15.17/doc/tcllib-1.12/license.terms

Would this be problematic to use as part of Cartopy?

pelson commented 8 years ago

Would this be problematic to use as part of Cartopy?

It wouldn't. Given the translative nature of what you are doing, it is grey as to whether the license terms hold in any case AFAICT. Go ahead and give it a shot!

Incidentally, to get any kind of performance, I suspect we will want to Cythonize the transformations. Do you have any experience writing in Cython?

jonathf commented 8 years ago

I don't have much experience with cython. I usually use scipy.weave for my bottlenecks.

I've made a raw python translation of the forward transformation. As far as I can tell, the heavy stuff are all available in the scipy.special collection. If this is the case, it should in practice allow us remove all bottle necks.

As for the inverse, it is too early to tell.

jonathf commented 8 years ago

Okay. I've made a translation for both forward and backward transformation. It is all numpy; no python-loops or other obvious bottlenecks I could think of.

Do you want me to make a pull request to cartopy?

pelson commented 8 years ago

Do you want me to make a pull request to cartopy?

Sure thing. Don't worry too much about where to put it within the repo, I'll happily try to deal with that later. When submitting the PR, please could you also take a look at https://github.com/SciTools/cartopy/blob/master/CONTRIBUTING.md.

Its been a while since I looked at the guts of cartopy's projection algorithm (>12 months), and I don't have a good estimate for how long it will take to plumb in a general Python function for forward and inverse transformations. As I say, this will be the first time that the projection comes from anything other than Proj.4 (which I also encourage you to contribute this projection to).

:+1:

jonathf commented 8 years ago

Done.

Note though that I've only added a simple doctest. I assume you will be able to expand in it to do a more rigourous test in the testsuite. But it should be documented well enough to understand what is going on, I think.

micahcochran commented 8 years ago

There has been some recent interest in adding this projection and similar onese to proj.4. There are reservations about using the TCL licensed code.

QuLogic commented 4 years ago

Pierce Quincuncial will likely be in Proj soon via https://github.com/OSGeo/PROJ/pull/2148