# Scale grid coordinates

**URL:** <https://forum.generic-mapping-tools.org/t/scale-grid-coordinates/5992>\
**Category:** Q&A\
**Created:** [June 13, 2025, 5:39pm UTC](https://forum.generic-mapping-tools.org/t/scale-grid-coordinates/5992 "2025-06-13T17:39:00Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andreas](https://avatars.discourse-cdn.com/v4/letter/a/ee7513/32.png) [@Andreas](https://forum.generic-mapping-tools.org/u/Andreas)\
**Post date:** [June 13, 2025, 5:39pm UTC](https://forum.generic-mapping-tools.org/t/scale-grid-coordinates/5992/1 "2025-06-13T17:39:00Z")

</div>

Is there a way to scale the grid coordinates?

I have a grid with the following extent:

```auto
$ gmt grdinfo is.tif -I1
-R321761/876155/7016802/7403589

```

I would like to edit the grid, and divide the coordinates by 1000, so that the extent becomes:

```auto
$ gmt grdinfo is.tif -I1
-R321.761/876.155/7016.802/7403.589

```

The **x\_inc** and **y\_inc** also have to be changed, but maybe this is implicit?

I was looking at [grdmath](https://docs.generic-mapping-tools.org/dev/grdmath.html), but didn’t find anything very obvious.

The [X and Y symbols](https://docs.generic-mapping-tools.org/dev/grdmath.html#symbols) may be interesting, but I dont’t understand how to use them; the list does not provide info about the number of arguments, as the other [operators](https://docs.generic-mapping-tools.org/dev/grdmath.html#operators) table does:

```auto
$ gmt grdmath is.tif X = temp.nc 
grdmath [WARNING]: 1 more operands left on the stack!

```

---

<div class="post-metadata">

**Author:** ![mkononets](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/mkononets/32/4029_2.png) [@mkononets](https://forum.generic-mapping-tools.org/u/mkononets)\
**Post date:** [June 13, 2025, 8:53pm UTC](https://forum.generic-mapping-tools.org/t/scale-grid-coordinates/5992/2 "2025-06-13T20:53:16Z")

</div>

[grdedit](https://docs.generic-mapping-tools.org/latest/grdedit.html#r)?

---

<div class="post-metadata">

**Author:** ![Andreas](https://avatars.discourse-cdn.com/v4/letter/a/ee7513/32.png) [@Andreas](https://forum.generic-mapping-tools.org/u/Andreas)\
**Post date:** [June 13, 2025, 9:04pm UTC](https://forum.generic-mapping-tools.org/t/scale-grid-coordinates/5992/3 "2025-06-13T21:04:37Z")

</div>

Yes, maybe that’ll work. Just input my ‘new’ region.

Thanks! Will try.

---

<div class="post-metadata">

**Author:** ![timhume](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/timhume/32/296_2.png) [@timhume](https://forum.generic-mapping-tools.org/u/timhume)\
**Post date:** [June 14, 2025, 6:30am UTC](https://forum.generic-mapping-tools.org/t/scale-grid-coordinates/5992/4 "2025-06-14T06:30:16Z")

</div>

If these data were in NetCDF format, the NetCDF operators (ncap2 in particular) would get you out of jail. Hopefully grdedit works - if you want a NetCDF operator solution let me know here and I’ll find the code.

---

<div class="post-metadata">

**Author:** ![Andreas](https://avatars.discourse-cdn.com/v4/letter/a/ee7513/32.png) [@Andreas](https://forum.generic-mapping-tools.org/u/Andreas)\
**Post date:** [June 14, 2025, 5:12pm UTC](https://forum.generic-mapping-tools.org/t/scale-grid-coordinates/5992/5 "2025-06-14T17:12:37Z")

</div>

@timhume My grid is absolutely available as netCDF (it’s converted to tif by me) - I’m very interested to see some NetCDF magic!

---

<div class="post-metadata">

**Author:** ![timhume](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/timhume/32/296_2.png) [@timhume](https://forum.generic-mapping-tools.org/u/timhume)\
**Post date:** [June 14, 2025, 10:35pm UTC](https://forum.generic-mapping-tools.org/t/scale-grid-coordinates/5992/6 "2025-06-14T22:35:30Z")

</div>

Hi Andreas,

Here’s how you do this to your original NetCDF file. If you don’t already have them on your computer, get the NetCDF operators from here: [https://nco.sourceforge.net/](https://nco.sourceforge.net/)

It’s highly likely your operating system’s packages or ports come with these, so installation should be easy enough.

I’m going to demonstrate on a file called `ecmwf_202506021200.nc` - your file will look different, but it should be easy enough to translate what is done here to your needs.

First examine the structure of your file with `ncdump`:

```auto
/Users/tim/ecmwf> ncdump -c ecmwf_202506021200.nc
netcdf ecmwf_202506021200 {
dimensions:
	longitude = 1440 ;
	latitude = 721 ;
	time = 41 ;
variables:
	float longitude(longitude) ;
		longitude:units = "degrees_east" ;
		longitude:long_name = "longitude" ;
	float latitude(latitude) ;
		latitude:units = "degrees_north" ;
		latitude:long_name = "latitude" ;
	int time(time) ;
		time:units = "hours since 1900-01-01 00:00:00.0" ;
		time:long_name = "time" ;
		time:calendar = "gregorian" ;
	float tp(time, latitude, longitude) ;
.
.
.
 longitude = -180, -179.75, -179.5, -179.25, -179, -178.75, -178.5, -178.25,
    -178, -177.75, -177.5, -177.25, -177, -176.75, -176.5, -176.25, -176,
    -175.75, -175.5, -175.25, -175, -174.75, -174.5, -174.25, -174, -173.75,
    -173.5, -173.25, -173, -172.75, -172.5, -172.25, -172, -171.75, -171.5
.
.
.
 latitude = 90, 89.75, 89.5, 89.25, 89, 88.75, 88.5, 88.25, 88, 87.75, 87.5,
    87.25, 87, 86.75, 86.5, 86.25, 86, 85.75, 85.5, 85.25, 85, 84.75, 84.5,
    84.25, 84, 83.75, 83.5, 83.25, 83, 82.75, 82.5, 82.25, 82, 81.75, 81.5,
.
.
.

```

The dimensions I want to scale down by 1000 are `longitude` and `latitude` which currently range from -180.0 to 179.75 and 90.0 to -90.0 respectively.

This is done easily with `ncap2` from the NetCDF operators:

```auto
ncap2 -O -s "longitude=longitude/1000; latitude=latitude/1000" ecmwf_202506021200.nc scaled.nc

```

Now if you run the previous `ncdump` command you’ll see this:

```auto
/Users/tim/ecmwf> ncdump -c scaled.nc
netcdf scaled {
dimensions:
	longitude = 1440 ;
	latitude = 721 ;
	time = 41 ;
variables:
	float longitude(longitude) ;
		longitude:long_name = "longitude" ;
		longitude:units = "degrees_east" ;
	float latitude(latitude) ;
		latitude:long_name = "latitude" ;
		latitude:units = "degrees_north" ;
.
.
.
 longitude = -0.18, -0.17975, -0.1795, -0.17925, -0.179, -0.17875, -0.1785,
    -0.17825, -0.178, -0.17775, -0.1775, -0.17725, -0.177, -0.17675, -0.1765,
    -0.17625, -0.176, -0.17575, -0.1755, -0.17525, -0.175, -0.17475, -0.1745,
.
.
.
 latitude = 0.09, 0.08975, 0.0895, 0.08925, 0.089, 0.08875, 0.0885, 0.08825,
    0.088, 0.08775, 0.0875, 0.08725, 0.087, 0.08675, 0.0865, 0.08625, 0.086,
    0.08575, 0.0855, 0.08525, 0.085, 0.08475, 0.0845, 0.08425, 0.084,
.
.
.

```

Which is probably all you need to do. But if you’re being picky, you’ll notice the units for the `longitude` and `latitude` dimensions are now incorrect (they’re still in units of `degrees_east` and `degrees_north` rather than in units of `kdegrees_east` and `kdegrees_north`). Another NetCDF operator, `ncatted` can solve this:

```auto
ncatted -O -a units,longitude,o,c,kdegrees_east \
    -a units,latitude,o,c,kdegrees_north scaled.nc scaled.nc

```

You can rerun `ncdump` to confirm the `units` attribute has indeed been changed.

---

<div class="post-metadata">

**Author:** ![Andreas](https://avatars.discourse-cdn.com/v4/letter/a/ee7513/32.png) [@Andreas](https://forum.generic-mapping-tools.org/u/Andreas)\
**Post date:** [June 16, 2025, 12:28pm UTC](https://forum.generic-mapping-tools.org/t/scale-grid-coordinates/5992/7 "2025-06-16T12:28:48Z")

</div>

Thank you so much @timhume!  
I’m going to play around with this.

(Not sure if I have time for much before summer though)
