Skip to content

Expand table-like input options for pygmt.surface #1443

@maxrjones

Description

@maxrjones

Description of the desired feature

Currently, the data parameter for pygmt.surface function accepts a data file name or a 2d numpy array with the tabular data. It would be helpful to expand the list of accepted input options to include pandas.DataFrame, xarray.Dataset, or geopandas.GeoDataFrame similar to blockmedian or plot.

To address, this issue you will need to change this block of code:

if kind == "file":
file_context = dummy_context(data)
elif kind == "matrix":
file_context = lib.virtualfile_from_matrix(data)
elif kind == "vectors":
file_context = lib.virtualfile_from_vectors(x, y, z)
else:
raise GMTInvalidInput("Unrecognized data type: {}".format(type(data)))

to:

            # Choose how data will be passed into the module
            file_context = lib.virtualfile_from_data(
                check_kind="vector", data=data, x=x, y=y, z=z
            )

update the data parameter description in the docstring to:

    data : str or {table-like}
        Pass in (x, y, z) or (longitude, latitude, elevation) values by
        providing a file name to an ASCII data table, a 2D
        {table-classes}.

and remove dummy_context from the import statements in pygmt/src/surface.py.

Are you willing to help implement and maintain this feature? I would be glad to help someone implement this feature request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    eswn-workshopGood issues for first-contributions during the ESWN-PyGMT workshopfeature requestNew feature wantedhelp wantedHelping hands are appreciated

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions