Segmentation Fault on gmt gridview while trying to put image on grid

Hello,

sorry I am a GMT newbie and struggling with my very first experiments with grdview.
I am trying to drape an image (a PNG file, but tested it with JPG too) on earth relief.
But I am getting - after some warnings I do not understand - a segmentation fault using GMT 6.3.0 under Ubuntu (22.04.02 LTS).

Insights appreciated !!

Regards, Ity

Code:
indent preformatted text by 4 spaces

#!/usr/bin/bash
# Region
minlon=8.3
maxlon=9.2
minlat=51.5
maxlat=52
minheight=0
maxheight=500
# Map resolution 

resolution=01m
# Overlay
overlay_inbound_file=overlay2.png

gmt begin region png
    gmt grdview @earth_relief_${resolution} -G${overlay_inbound_file} -R${minlon}/${maxlon}/${minlat}/${maxlat}/${minheight}/${maxheight} -Qi
gmt end

Output:
$ ./min.sh
grdview [WARNING]: (w - x_min) must equal (NX + eps) * x_inc), where NX is an integer and |eps| <= 0.0001.
grdview [WARNING]: w reset from 8.3 to 7
grdview [WARNING]: (e - x_min) must equal (NX + eps) * x_inc), where NX is an integer and |eps| <= 0.0001.
grdview [WARNING]: e reset from 9.2 to 10
grdview [WARNING]: (s - y_min) must equal (NY + eps) * y_inc), where NY is an integer and |eps| <= 0.0001.
grdview [WARNING]: s reset from 51.5 to 51
ERROR: Caught signal number 11 (Segmentation fault) at
/lib/x86_64-linux-gnu/libgmt.so.6(gmt_gdalread+0x245a)[0x7f9ccccb4c1a]
[0x55d6cb801001]
malloc_consolidate(): invalid chunk size
./min.sh: line 19: 142084 Aborted gmt grdview @earth_relief_${resolution} -G${overlay_inbound_file} -R${minlon}/${maxlon}/${minlat}/${maxlat}/${minheight}/${maxheight} -Qi

Cannot reproduce without an example (with data), but some observations:

  1. All the warnings relate to your given w/e/s/n which are not multiple of the grid you extract. Not harmful.
  2. See if we can work around it with running grdcut first to extract that topography grid and then pass that to grdview.

Hello,

Thanks regarding the warning!

Regarding the segmentation fault:
Both test files atteched, the PNG and the JPG. Both of them random pictures w/o any useful content… Useful for first steps only.

Regards, Ity

Unclear. Your blue blob JPG is a 3000x3000 image while your desired geographic area -R8.3/9.2/51.5/52 is 55x31. I found also that the crash was due to the “jpeg” extension which GMT did not check for. I will fix that.
You specify no vertical scale and no vantage point. If I add those and a frame I get something like the below image. Your white pixels buries the topography since it is white, not NaNs or transparent pixels. I think your challenges are

  1. How to relate your square image (which has a map frame and white margins that I do not know if you want to plot inside a geographic map)
  2. For now, use .jpg until we fix that in 6.5
  3. Add some vertical scaling and vantage point. Draping makes no sense unless you do.
  4. Have transparent pixels (will that work, @Joaquim ?)

gmt grdview @earth_relief_01m -Goverlay.jpg -R8.3/9.2/51.5/52/0/500 -Qi -JZ2i -p135/35 -B -png map

Even with that line I get a seg-fault, might be a problem with Ubuntus GMT 6.3.0 package then (which I use within WSL2 under Win11). Next step for me will be to check how to update to 6.4.
(and yes, then I have some todos learning howo to tackle scaling/vantage/…)

Thanks ! Regards, ity

gmt grdview @earth_relief_01m -Goverlay.jpg -R8.3/9.2/51.5/52/0/500 -Qi -JZ2i -p135/35 -B -png map
grdview [WARNING]: (w - x_min) must equal (NX + eps) * x_inc), where NX is an integer and |eps| <= 0.0001.
grdview [WARNING]: w reset from 8.3 to 7
grdview [WARNING]: (e - x_min) must equal (NX + eps) * x_inc), where NX is an integer and |eps| <= 0.0001.
grdview [WARNING]: e reset from 9.2 to 10
grdview [WARNING]: (s - y_min) must equal (NY + eps) * y_inc), where NY is an integer and |eps| <= 0.0001.
grdview [WARNING]: s reset from 51.5 to 51
ERROR: Caught signal number 11 (Segmentation fault) at
/lib/x86_64-linux-gnu/libgmt.so.6(gmt_gdalread+0x245a)[0x7f382cf3dc1a]
[0x55be69151000]
malloc_consolidate(): invalid chunk size
Aborted

Most likely 6.3 problem, but note I am running the master build from GitHub (i.e., proto 6.5) and not 6.4 so who knows when this was fixed or if it is something else.

Hello Paul,

i tried updating to 6.4.0, but that did not work out (same symptom, see below).

Getting up 6.5 from source incl. dependencies… I will giv it a try, but might be to high a bar.

Regards, ity

$ lsb_release -a

No LSB modules are available.

Distributor ID: Ubuntu

Description: Ubuntu 23.04

Release: 23.04

Codename: lunar

$ gmt --version

6.4.0

$ gmt grdview @earth_relief_01m -Goverlay.jpg -R8.3/9.2/51.5/52/0/500 -Qi -JZ2i -p135/35 -B -png map

grdview [WARNING]: (w - x_min) must equal (NX + eps) * x_inc), where NX is an integer and |eps| <= 0.0001.

grdview [WARNING]: w reset from 8.3 to 8

grdview [WARNING]: (e - x_min) must equal (NX + eps) * x_inc), where NX is an integer and |eps| <= 0.0001.

grdview [WARNING]: e reset from 9.2 to 10

grdview [WARNING]: (s - y_min) must equal (NY + eps) * y_inc), where NY is an integer and |eps| <= 0.0001.

grdview [WARNING]: s reset from 51.5 to 51

ERROR: Caught signal number 11 (Segmentation fault) at

/lib/x86_64-linux-gnu/libgmt.so.6(gmt_gdalread+0x2742)[0x7f8d522b4122]

[0x55ed56291001]

malloc_consolidate(): invalid chunk size

Aborted

GMT 6.4 on macOS crashes as well, so this must have been fixed the last year or so.

I think transparency should work (not sure though) but jpg does not support transparency.

Thanks a lot so far! And thanks for checking on macOS too!
(getting 6.5-dev up and running on my system is a little to ambitous for a rookie like me… Will have to wait then. But there is a lot of other stuff to explore with GMT!

Hello,

fyi, found today time to install and retest with dev 6.5.0.dev9+0776994 from conda-forge.

gmt --version
6.5.0

But i still get segmentation fault with either JPG or PNG overlay.

Regards & Happy new year!