# Getting malloc errors with grdimage of GeoTIFF in oblique Mercator projection(-JOa)

**URL:** <https://forum.generic-mapping-tools.org/t/getting-malloc-errors-with-grdimage-of-geotiff-in-oblique-mercator-projection-joa/2570>\
**Category:** Q&A\
**Created:** [January 30, 2022, 6:01am UTC](https://forum.generic-mapping-tools.org/t/getting-malloc-errors-with-grdimage-of-geotiff-in-oblique-mercator-projection-joa/2570 "2022-01-30T06:01:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kyleedwardbradley](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/kyleedwardbradley/32/1407_2.png) [@kyleedwardbradley](https://forum.generic-mapping-tools.org/u/kyleedwardbradley)\
**Post date:** [January 30, 2022, 6:01am UTC](https://forum.generic-mapping-tools.org/t/getting-malloc-errors-with-grdimage-of-geotiff-in-oblique-mercator-projection-joa/2570/1 "2022-01-30T06:01:04Z")

</div>

Hi, I am getting a malloc error and crash when plotting a GeoTIFF with grdimage in an oblique Mercator projection using -JOa (classic mode, GMT 6.4.0\_0c12c73\_2022.01.17). The same image plots just fine in other projections (e.g. -JQ), and my commands work with other modules like pscoast, psxy, pscmeca, etc so I don’t think it’s a problem with my -R or -J format. As always, thanks for any help and I’m happy to provide more details if needed.

kmbp:~ kylebradley$ **gmt grdinfo colored\_relief.tif**  
colored\_relief.tif: Title: Grid imported via GDAL  
colored\_relief.tif: Command:  
colored\_relief.tif: Remark:  
colored\_relief.tif: Pixel node registration used [Geographic grid]  
colored\_relief.tif: Grid file format: gd = Import/export through GDAL  
colored\_relief.tif: x\_min: 154.975 x\_max: 159.025 x\_inc: 0.00833333333333 (30 sec) name: x n\_columns: 486  
colored\_relief.tif: y\_min: -9.71666666667 y\_max: -6.275 y\_inc: 0.00833333333333 (30 sec) name: y n\_rows: 413  
colored\_relief.tif: v\_min: 1.79769313486e+308 v\_max: -1.79769313486e+308 name: z  
colored\_relief.tif: scale\_factor: 1 add\_offset: 0  
colored\_relief.tif: Default CPT:  
+proj=longlat +datum=WGS84 +no\_defs

kmbp:~ kylebradley$ **gmt grdimage colored\_relief.tif -R155/159/-10/-6 -JQ155/7i -Bxaf -Byaf \> testimg.ps**  
Successfully plots the image

kmbp:~ kylebradley$ **gmt grdimage colored\_relief.tif -R-200/200/-100/100+uk -JOa157/-8/122/7i -Bxaf -Byaf \> testimg.ps**  
gmt(32334,0x110f47dc0) malloc: can’t allocate region  
:\*\*\* mach\_vm\_map(size=18446744073709535232, flags: 100) failed (error code=3)  
gmt(32334,0x110f47dc0) malloc: \*\*\* set a breakpoint in malloc\_error\_break to debug  
grdimage [ERROR]: gdalread: failure to allocate enough memory  
grdimage [ERROR]: ERROR reading image with gdalread.  
grdimage (gmtapi\_import\_image): Could not read from file [colored\_relief.tif]  
[Session gmt (0)]: Error returned from GMT API: GMT\_IMAGE\_READ\_ERROR (22)  
[Session gmt (0)]: Error returned from GMT API: GMT\_IMAGE\_READ\_ERROR (22)

Using a different form of -R also doesn’t work:

kmbp:~ kylebradley$ **gmt grdimage colored\_relief.tif -R155/-7.8/159/-8.2+r -JOa157/-8/122/7i -Bxaf -Byaf \> testimg.ps**  
gmt(32400,0x10cfd2dc0) malloc: can’t allocate region  
:\*\*\* mach\_vm\_map(size=18446744073709531136, flags: 100) failed (error code=3)  
gmt(32400,0x10cfd2dc0) malloc: \*\*\* set a breakpoint in malloc\_error\_break to debug  
grdimage [ERROR]: gdalread: failure to allocate enough memory  
grdimage [ERROR]: ERROR reading image with gdalread.  
grdimage (gmtapi\_import\_image): Could not read from file [colored\_relief.tif]  
[Session gmt (0)]: Error returned from GMT API: GMT\_IMAGE\_READ\_ERROR (22)  
[Session gmt (0)]: Error returned from GMT API: GMT\_IMAGE\_READ\_ERROR (22)

If I convert the TIFF to netCDF using grdconvert, I can plot the result just fine:  
kmbp:~ kylebradley$ **gmt grdconvert colored\_relief.tif colored\_relief.nc**  
kmbp:~ kylebradley$ **gmt grdimage colored\_relief.nc -R-200/200/-100/100+uk -JOa157/-8/122/7i -Bxaf -Byaf \> testimg.ps**  
Success but the image isn’t useful as it’s only one band of the TIFF.

[colored\_relief.tif](https://forum.generic-mapping-tools.org/uploads/short-url/w4ZzwzyaKYLx1zFu1EvRmoB1Va5.tif) (528.8 KB)

---

<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:** [January 31, 2022, 3:45am UTC](https://forum.generic-mapping-tools.org/t/getting-malloc-errors-with-grdimage-of-geotiff-in-oblique-mercator-projection-joa/2570/2 "2022-01-31T03:45:35Z")

</div>

Hello kyleedwardbradley.

It was a bug that was fixed by Paul and just merge into master.

---

<div class="post-metadata">

**Author:** ![kyleedwardbradley](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/kyleedwardbradley/32/1407_2.png) [@kyleedwardbradley](https://forum.generic-mapping-tools.org/u/kyleedwardbradley)\
**Post date:** [January 31, 2022, 5:44am UTC](https://forum.generic-mapping-tools.org/t/getting-malloc-errors-with-grdimage-of-geotiff-in-oblique-mercator-projection-joa/2570/3 "2022-01-31T05:44:10Z")

</div>

Great! I have recompiled and can verify that the oblique Mercator plots are working for me now. Thanks again for the quick fix, always appreciated!
