Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get projection/crs from GMT_GRID_HEADER #3470

Open
weiji14 opened this issue Sep 30, 2024 · 0 comments
Open

Get projection/crs from GMT_GRID_HEADER #3470

weiji14 opened this issue Sep 30, 2024 · 0 comments
Labels
feature request New feature wanted

Comments

@weiji14
Copy link
Member

weiji14 commented Sep 30, 2024

Description of the desired feature

This is a feature request to add a method for getting the projected coordinate reference system (CRS) from a GMT_GRID (#2398)/GMT_IMAGE (#3338)/GMT_CUBE (#3150) struct when parsing a NetCDF/GeoTIFF file. Motivation from #2235 (comment):

In GMT_IMAGE.to_dataarray(), perhaps we should parse the header->ProjRefPROJ4 and set the correct CRS to the 3-band xarray.DataArray. ...

Yeah, I was thinking of parsing the projection information from the header when you mentioned this ProjRefPROJ4 field at #3128 (comment). But ideally we'll need to handle PROJ4/WKT/EPSG:

# Referencing system string in PROJ.4 format
("ProjRefPROJ4", ctp.c_char_p),
# Referencing system string in WKT format
("ProjRefWKT", ctp.c_char_p),
# Referencing system EPSG code
("ProjRefEPSG", ctp.c_int),

...

Implementation details

Use pyproj.CRS.from_string to make a CRS from PROJ4/WKT/EPSG. Create a new method/property under _GMT_GRID_HEADER at https://github.com/GenericMappingTools/pygmt/blob/v0.13.0/pygmt/datatypes/header.py#L67

We can also consider exposing a .gmt.proj or .gmt.crs xarray accessor property (xref #499). But note that there is some discussion at geoxarray/geoxarray#21 on whether there should be a common .crs accessor in some xarray library that can be used across rioxarray/geoxarray/odc-geo/etc.

Are you willing to help implement and maintain this feature?

Yes

@weiji14 weiji14 added the feature request New feature wanted label Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature wanted
Projects
None yet
Development

No branches or pull requests

1 participant