Description of the desired feature
The pygmt.info function should accept pandas.DataFrame or 2D numpy.array matrices as input. This was mentioned in passing when pygmt.info was originally implemented at #106 (comment). Currently it can only handle filename (str) types:
|
if not isinstance(fname, str): |
|
raise GMTInvalidInput("'info' only accepts file names.") |
What I'm particularly interested in is getting a nicely rounded xmin/xmax/ymin/ymax 'region' by simply passing in a pandas.DataFrame (Option 3 in the related issue at #147). Something like this:
import pandas as pd
df: pd.DataFrame = pygmt.datasets.load_ocean_ridge_points()
region = pygmt.info(df, spacing="0.1") # pygmt.info("@ridge.txt", I="0.1")
print(region)
# would output '-R-180/180/-65.7/86.8\n', or better, a proper python list
Yes, it's possible to do region = [df.x.min(), df.x.max(), df.y.min(), df.y.max()], but gmtinfo -I does rounding (and I believe it rounds outside of the tight region?), and it has other smart functionality too.
It shouldn't be too hard to make pygmt.info support non-filename types, just need to use lib.virtualfile_from_vectors or the like.
Note that the return values of pygmt.info should be discussed at #147. This issue only tackles the input format type. Perhaps we should handle #147 before this tackling this issue.
Are you willing to help implement and maintain this feature? Yes