# Greenspline to smooth a surface

**URL:** <https://forum.generic-mapping-tools.org/t/greenspline-to-smooth-a-surface/4010>\
**Category:** Q&A\
**Tags:** gmt\
**Created:** [June 6, 2023, 3:46pm UTC](https://forum.generic-mapping-tools.org/t/greenspline-to-smooth-a-surface/4010 "2023-06-06T15:46:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jianbo](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/jianbo/32/3197_2.png) [@Jianbo](https://forum.generic-mapping-tools.org/u/Jianbo)\
**Post date:** [June 6, 2023, 3:46pm UTC](https://forum.generic-mapping-tools.org/t/greenspline-to-smooth-a-surface/4010/1 "2023-06-06T15:46:00Z")

</div>

Hello,

I have a 2-D netcdf grid file with three columns: lat, lon and elevation (i.e., a 3-D topographic surface), which can be visualized by GMT module grdview. Now I am trying to generate a new surface at new positions which are nodes of an unstructured triangular mesh. I wonder how I can use greenspline to “interpolate” the elevations at the new positions ? A related question is, can we use greenspline to smooth the original surface ? If not, are there other options ?

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [June 6, 2023, 5:38pm UTC](https://forum.generic-mapping-tools.org/t/greenspline-to-smooth-a-surface/4010/2 "2023-06-06T17:38:27Z")

</div>

> [@Jianbo](#):
>
> I have a 2-D netcdf grid file with three columns: lat, lon and elevation

Not exactly. A regular grid has only the third variable (plus a mechanism to compute the horizontal coordinates.)

> [@Jianbo](#):
>
> Now I am trying to generate a new surface at new positions which are nodes of an unstructured triangular mesh.

Extract the x,y values of those nodes and feed than to `grdtrack`

> [@Jianbo](#):
>
> A related question is, can we use greenspline to smooth the original surface ?

`greenspline` is a slow program (but I have little experience with it). Better use `grdfilter`.

---

<div class="post-metadata">

**Author:** ![Jianbo](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/jianbo/32/3197_2.png) [@Jianbo](https://forum.generic-mapping-tools.org/u/Jianbo)\
**Post date:** [June 13, 2023, 2:03am UTC](https://forum.generic-mapping-tools.org/t/greenspline-to-smooth-a-surface/4010/3 "2023-06-13T02:03:21Z")

</div>

Hi Joaquim,

Thanks for the suggestions ! I’ve tried grdfilter and indeed, it’s much faster than greenspline. Now another issue is grid conversion: (lon, lat, elv) to (x,y, elv). It appears mapproject is the right program to do this, but I haven’t got it working.

I wonder how I can convert my grid file (xxx.nc with netCDF format) with geographic coordinates into another grid with x & y in a simple Mercator projection, for example, -JM. Because eventually, I need this new grid to build a regional geological model.

Many thanks !

---

<div class="post-metadata">

**Author:** ![PlanetGus](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/planetgus/32/303_2.png) [@PlanetGus](https://forum.generic-mapping-tools.org/u/PlanetGus)\
**Post date:** [June 13, 2023, 6:54am UTC](https://forum.generic-mapping-tools.org/t/greenspline-to-smooth-a-surface/4010/4 "2023-06-13T06:54:08Z")

</div>

If it’s a grid, grdproject does the work I think

---

<div class="post-metadata">

**Author:** ![Jianbo](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/jianbo/32/3197_2.png) [@Jianbo](https://forum.generic-mapping-tools.org/u/Jianbo)\
**Post date:** [June 15, 2023, 9:55am UTC](https://forum.generic-mapping-tools.org/t/greenspline-to-smooth-a-surface/4010/5 "2023-06-15T09:55:35Z")

</div>

Thanks, looks like the grdproject did the job !
