Create Projection classes instead of strings
See original GitHub issueDescription of the desired feature
The Figure methods take a projection argument that is using the same arguments as GMT -J ("M10i" for Mercator 10 inches). But a lot of projections have many arguments and it’s impossible to remember them all. A relatively simple alternative would be to implement classes (based on a single Projection class maybe) that take the projection arguments in the constructor (and so allows tab-completion). The key would be for these classes to define a __str__ method so that when str is called on them, they produce the GMT -J code. For example:
>>> proj = pygmt.Orthographic(central_longitude=10, central_latitude=52, width=10)
>>> print(str(proj))
G10/52/10
The plotting method pre-processing would only have to call str on projection, which works fine if you pass in a string as well.
Are you willing to help implement and maintain this feature? Yes but I’d welcome anyone else who wants to try 😃
Issue Analytics
- State:
- Created 4 years ago
- Comments:15 (10 by maintainers)

Top Related StackOverflow Question
Hi everyone, I’m just having a quick exploration into this issue whilst at the FOSS4G Oceania Community Day.
I think attrs is a good idea, so I’ll prototype out something over the weekend and see what you think. I have used attrs in a similar fashion to what is being described in this issue.
I’ll try to squish some time in and push through the last bits of the this over the next few weeks. Spare time completely disappeared for me the past year.