# How to use xyztogrd and import and plot .grd files

**URL:** <https://forum.generic-mapping-tools.org/t/how-to-use-xyztogrd-and-import-and-plot-grd-files/1534>\
**Category:** Q&A\
**Tags:** gmt\
**Created:** [April 3, 2021, 5:58pm UTC](https://forum.generic-mapping-tools.org/t/how-to-use-xyztogrd-and-import-and-plot-grd-files/1534 "2021-04-03T17:58:47Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Roshlion](https://avatars.discourse-cdn.com/v4/letter/r/3d9bf3/32.png) [@Roshlion](https://forum.generic-mapping-tools.org/u/Roshlion)\
**Post date:** [April 3, 2021, 5:58pm UTC](https://forum.generic-mapping-tools.org/t/how-to-use-xyztogrd-and-import-and-plot-grd-files/1534/1 "2021-04-03T17:58:47Z")

</div>

Hi, I am stuck on importing and plotting a .grd file. It has 4 columns with node ID, Lat, Long, and elevation respectively. I wanted to convert it into netcdf by using grdinfo or xyztogrd but I am a little confused on how to go about this. Do I have to use -f to assign each column to a specific input or is there a different way to do this.

---

<div class="post-metadata">

**Author:** ![pwessel](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/pwessel/32/30_2.png) [@pwessel](https://forum.generic-mapping-tools.org/u/pwessel)\
**Post date:** [April 3, 2021, 6:17pm UTC](https://forum.generic-mapping-tools.org/t/how-to-use-xyztogrd-and-import-and-plot-grd-files/1534/2 "2021-04-03T18:17:38Z")

</div>

If it is an equidistant grid then it would be something like this (since we would expect lon,lat,z on input)

gmt xyz2grd -i2,1,3 -R… -I… -fg -Goutput.grd input.txt

you may possibly need -r if your grid is pixel-registered and not gridline-registered.

---

<div class="post-metadata">

**Author:** ![Roshlion](https://avatars.discourse-cdn.com/v4/letter/r/3d9bf3/32.png) [@Roshlion](https://forum.generic-mapping-tools.org/u/Roshlion)\
**Post date:** [April 7, 2021, 4:50pm UTC](https://forum.generic-mapping-tools.org/t/how-to-use-xyztogrd-and-import-and-plot-grd-files/1534/3 "2021-04-07T16:50:35Z")

</div>

ok thank you, so the -I is what dictates order of columns. What about the first column, node ID. Do I just remove it?

---

<div class="post-metadata">

**Author:** ![pwessel](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/pwessel/32/30_2.png) [@pwessel](https://forum.generic-mapping-tools.org/u/pwessel)\
**Post date:** [April 7, 2021, 5:47pm UTC](https://forum.generic-mapping-tools.org/t/how-to-use-xyztogrd-and-import-and-plot-grd-files/1534/4 "2021-04-07T17:47:52Z")

</div>

No need, it is not listed in the -i option that selects the columns.

---

<div class="post-metadata">

**Author:** ![Esteban82](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/esteban82/32/54_2.png) [@Esteban82](https://forum.generic-mapping-tools.org/u/Esteban82)\
**Post date:** [April 7, 2021, 8:40pm UTC](https://forum.generic-mapping-tools.org/t/how-to-use-xyztogrd-and-import-and-plot-grd-files/1534/5 "2021-04-07T20:40:39Z")

</div>

GMT starts counting with 0. So the column -i1 is the second, not the first.

---

<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:** [April 7, 2021, 10:38pm UTC](https://forum.generic-mapping-tools.org/t/how-to-use-xyztogrd-and-import-and-plot-grd-files/1534/6 "2021-04-07T22:38:51Z")

</div>

> [@Esteban82](#):
>
> -i2 is the second

The third you mean 🙂

---

<div class="post-metadata">

**Author:** ![Esteban82](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/esteban82/32/54_2.png) [@Esteban82](https://forum.generic-mapping-tools.org/u/Esteban82)\
**Post date:** [April 8, 2021, 12:13am UTC](https://forum.generic-mapping-tools.org/t/how-to-use-xyztogrd-and-import-and-plot-grd-files/1534/7 "2021-04-08T00:13:01Z")

</div>

Fixed
