mdtanker / polartoolkit

Helpful tools for polar researchers

Home Page:http://polartoolkit.readthedocs.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Switch to rioxarray for reprojecting grids

mdtanker opened this issue · comments

Description of the desired feature:

PyGMT grdsample seems to be slow and doesn't handle EPSG:3031 very well. Rioxarray is efficient and seems to work well for dataarray reprojections.

Here is an example:

# write the current projection
grid.rio.write_crs("EPSG:9354", inplace=True)
# confirm that it worked 
assert grid.rio.crs == "EPSG:9354"

# reproject
reprojected = grid.rio.reproject("epsg:3031")
# confirm that it worked 
assert reprojected.rio.crs == "EPSG:3031"

# need to save to .nc and reload, issues with pygmt
reprojected.to_netcdf("tmp.nc")
processed = xr.load_dataset("tmp.nc").z

# re-set projection
processed.rio.write_crs("EPSG:3031", inplace=True)
assert processed.rio.crs == "EPSG:3031"

Currently PyGMT has an issue with using the dataarray once it's been reprojected, so here we save it to a .nc and reload it.

Fetch calls to implement this switch for:

  • IBCSO bed and surface
  • GlobSed sediment thickness
  • Eigen gravity
  • An crustal thickness
  • Losing-Ebbing GHF
  • An GHF

Are you willing to help implement and maintain this feature?

Have coverted all pygmt.grdproject() to rio.reproject, except for Eigen gravity and Losing-Ebbing GHF which had some issues. I will keep those as pygmt grdproject for now as they have no issues.