GenericMappingTools / GenericMappingTools/pygmt
Create Projection classes instead of strings
- Dominant language
- Python
- Stars
- 874
- Forks
- 255
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 40
Description
**Description 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:
```python
>>> 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 :)
Contributor guide
Assessment
This issue has not been assessed yet.