# Xesmf regridding projected coordinate system

**URL:** <https://discourse.pangeo.io/t/xesmf-regridding-projected-coordinate-system/2591>\
**Category:** Science\
**Created:** [July 18, 2022, 4:23pm UTC](https://discourse.pangeo.io/t/xesmf-regridding-projected-coordinate-system/2591 "2022-07-18T16:23:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rwegener2](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pangeo.io/rwegener2/32/887_2.png) [@rwegener2](https://discourse.pangeo.io/u/rwegener2)\
**Post date:** [July 18, 2022, 4:23pm UTC](https://discourse.pangeo.io/t/xesmf-regridding-projected-coordinate-system/2591/1 "2022-07-18T16:23:49Z")

</div>

Hello Pangeo people 👋

I am trying to use [xesmf](https://github.com/pangeo-data/xESMF) for regridding an image with a projected coordinate system (UTM Easting/Northing in meters, instead of lat/lon in degrees) but I’m not able to accurately transform my data. I am able to create a Regridder function and run it, but the plot of my transformed data does not match the plot of my input data.

 ![xesmf_projectedCRS_mystery](https://canada1.discourse-cdn.com/flex030/uploads/pangeo/original/2X/4/420d0d7a136cacf5828509437d66607c95493b05.jpeg)

All of the examples of curvilinear coordinate transformation I have found use lat/lon, so my question is: is using projected/UTM grids not supported by xESMF or is this probably an issue in my code?

An example code using a ~650KB version of my data (and the steps/naming convention of the [curvilinear tutorial](https://xesmf.readthedocs.io/en/latest/notebooks/Curvilinear_grid.html)) is in [this gist](https://gist.github.com/rwegener2/b6f667ca8586ed280bda585c6e60334e) and uses [this little chunk of data](https://github.com/rwegener2/sarp_lessons/raw/main/student_data/example_data.nc), if that is helpful.

Thanks for the help and especially for maintaining such a great package!

---

<div class="post-metadata">

**Author:** ![dcherian](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pangeo.io/dcherian/32/2235_2.png) [@dcherian](https://discourse.pangeo.io/u/dcherian)\
**Post date:** [July 19, 2022, 1:43am UTC](https://discourse.pangeo.io/t/xesmf-regridding-projected-coordinate-system/2591/2 "2022-07-19T01:43:00Z")

</div>

Yeah I suspect Xesmf doesn’t deal with projections. See [Example - Reproject — rioxarray 0.11.0 documentation](https://corteva.github.io/rioxarray/stable/examples/reproject.html)

cc @JessicaS11 @scottyhq

---

<div class="post-metadata">

**Author:** ![jhamman](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pangeo.io/jhamman/32/34_2.png) [@jhamman](https://discourse.pangeo.io/u/jhamman)\
**Post date:** [July 20, 2022, 9:42pm UTC](https://discourse.pangeo.io/t/xesmf-regridding-projected-coordinate-system/2591/3 "2022-07-20T21:42:05Z")

</div>

This is indeed a tricky problem to sort through. We’ve recently managed to make something work using xesmf and custom projections.

We’ve done this by manually creating a target dataset with coordinates that xesmf can interpret. Below is an example from our code base that does this for the web-mercator projection (`epsg:3857`).

> <https://github.com/carbonplan/ndpyramid/blob/4566a5b5988758625e8220bb20aacc1712fd0eeb/ndpyramid/regrid.py#L65-L106>

Once we have this target grid dataset generated, we use xesmf directly:

```python
regridder = xe.Regridder(ds_in, ds_target, ...)
ds_regridded = regridder(ds_in)

```
