Skip to content

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

Closed

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.

Activity

  1. added
    feature request
    eswn-workshop
    help wanted
    on Aug 13, 2021
  2. maxrjones commented on Aug 19, 2021

    @maxrjones
    MemberAuthor

    @daroari is going to work on this today!

  3. added this to the 0.5.0 milestone on Sep 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    eswn-workshopfeature requesthelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions