GenericMappingTools / GenericMappingTools/pygmt

Create Projection classes instead of strings

Open
#356 15 comments 0 reactions 0 assignees View on GitHub
feature request help wanted
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.