# Grdcut warping and distorting output raster

**URL:** <https://forum.generic-mapping-tools.org/t/grdcut-warping-and-distorting-output-raster/1523>\
**Category:** Q&A\
**Tags:** gmt\
**Created:** [April 1, 2021, 9:04pm UTC](https://forum.generic-mapping-tools.org/t/grdcut-warping-and-distorting-output-raster/1523 "2021-04-01T21:04:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jpschmidt](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/jpschmidt/32/700_2.png) [@jpschmidt](https://forum.generic-mapping-tools.org/u/jpschmidt)\
**Post date:** [April 1, 2021, 9:04pm UTC](https://forum.generic-mapping-tools.org/t/grdcut-warping-and-distorting-output-raster/1523/1 "2021-04-01T21:04:26Z")

</div>

I am having an issue that has recently occurred with newer versions of GMT. I had a netCDF raster image of central NM that I was cutting with grdcut in using the following lines

```
>> LATMIN=33.8000462963
>> LATMAX=34.6204166667
>> LONMIN=-107.251898148
>> LONMAX=-106.497453704
>> gmt grdcut smb_elevation.nc -R$LONMIN/$LONMAX/$LATMIN/$LATMAX -Gsmb_topo.nc -V

```

As I mentioned, this was line of code was working just fine prior to upgrading GMT. I’ll also note that I have had to upgrade my macbook to Big Sur recently so a lot of upgrades have occurred recently. This line specifically seems to later my output \*.nc file so that it looks completely warped. Here is the verbose output from executing that line.

> grdcut [INFORMATION]: Processing input grid  
> grdcut [INFORMATION]: File smb\_elevation.nc reads with GDAL driver HFA  
> grdcut [INFORMATION]: Cartesian input grid  
> grdcut [INFORMATION]: Round-off patrol changed grid limit for xmin from -108.0005092597349 to -108.0005092597349  
> grdcut [INFORMATION]: Round-off patrol changed grid limit for xmax from -105.9994907412076 to -105.9994907412076  
> grdcut [INFORMATION]: Round-off patrol changed grid limit for ymin from 32.99949074088585 to 32.99949074088585  
> grdcut [INFORMATION]: Round-off patrol changed grid limit for ymax from 35.00050925941316 to 35.00050925941316  
> grdcut [INFORMATION]: Reading grid from file smb\_elevation.nc  
> grdcut [INFORMATION]: Read band(s): 1  
> grdcut [INFORMATION]: Set boundary condition for all edges: natural  
> grdcut [INFORMATION]: Set boundary condition for left edge: natural  
> grdcut [INFORMATION]: Set boundary condition for right edge: natural  
> grdcut [INFORMATION]: Set boundary condition for bottom edge: natural  
> grdcut [INFORMATION]: Set boundary condition for top edge: natural  
> grdcut [INFORMATION]: File spec: W E S N dx dy n\_columns n\_rows:  
> grdcut [INFORMATION]: Old:grdcut [INFORMATION]: -108.00050926 -105.999490741 32.9994907409 35.0005092594 9.2592592538e-05 9.25925925959e-05 21612 21612  
> grdcut [INFORMATION]: New:grdcut [INFORMATION]: -107.251898148 -106.497453704 33.8000462963 34.6204166667 9.2592592538e-05 9.25925925959e-05 8149 8861  
> grdcut [INFORMATION]: Writing grid to file smb\_topo.nc  
> grdcut [INFORMATION]: Proj4 string to be converted to WKT:  
> +proj=longlat +datum=NAD83 +no\_defs  
> grdcut [INFORMATION]: WKT converted from proj4 string:  
> GEOGCS[“unknown”,  
> DATUM[“North\_American\_Datum\_1983”,  
> SPHEROID[“GRS 1980”,6378137,298.257222101,  
> AUTHORITY[“EPSG”,“7019”]],  
> AUTHORITY[“EPSG”,“6269”]],  
> PRIMEM[“Greenwich”,0,  
> AUTHORITY[“EPSG”,“8901”]],  
> UNIT[“degree”,0.0174532925199433,  
> AUTHORITY[“EPSG”,“9122”]],  
> AXIS[“Longitude”,EAST],  
> AXIS[“Latitude”,NORTH]]

I can follow most of the output till the line about Proj4 string to be converted to WKT. I’ll also give the output from grdinfo.

> smb\_elevation.nc: Title: Grid imported via GDAL  
> smb\_elevation.nc: Command:  
> smb\_elevation.nc: Remark:  
> smb\_elevation.nc: Gridline node registration used [Geographic grid]  
> smb\_elevation.nc: Grid file format: gd = Import/export through GDAL  
> smb\_elevation.nc: x\_min: -108.00050926 x\_max: -105.999490741 x\_inc: 9.2592592593e-05 name: x n\_columns: 21612  
> smb\_elevation.nc: y\_min: 32.9994907409 y\_max: 35.0005092594 y\_inc: 9.2592592593e-05 name: y n\_rows: 21612  
> smb\_elevation.nc: z\_min: 1259.08984375 z\_max: 2504.15893555 name: z  
> smb\_elevation.nc: scale\_factor: 1 add\_offset: 0  
> +proj=longlat +datum=NAD83 +no\_defs

Attached is an image from QGIS where I could look at both rasters and you can see how the output raster gets warped after the grdcut conversion. the original “smb\_elevation.nc” was created in QGIS from image rasters downloaded from the USGS national map as IMG formatted files. For easy use in GMT, I did the conversion here. I’m not sure if projection/header information is incorrect, but this function (grdcut) was working on this file before I had to upgrade my GMT package. Any help or advice on how to work this would be appreciated.

 ![Screen Shot 2021-04-01 at 4.59.48 PM](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/2X/6/66ab1bb60a7ca0013870ea1e1930a59ac1faadc7.jpeg)

---

<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:48pm UTC](https://forum.generic-mapping-tools.org/t/grdcut-warping-and-distorting-output-raster/1523/2 "2021-04-03T18:48:40Z")

</div>

Hard to examine without being able to recreate - and I know your input grid is very big. Maybe @Joaquim has some thoughts on how to sort this out?

---

<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:** [April 3, 2021, 11:14pm UTC](https://forum.generic-mapping-tools.org/t/grdcut-warping-and-distorting-output-raster/1523/3 "2021-04-03T23:14:53Z")

</div>

Have no idea. I guess that _raster images_ are actually grids, right?  
What happen when you do a `grdimage` plot of the grdcut’ed grid? Does it screws for all sizes of the sub-region or only big ones?
