grdimage/Earth Releif Model Plot problem

Hello,
I am running PyGMT through anaconda (in a separate environment as suggested in the installation guide) on Ubuntu 18.04 LTS.
As I am new to PyGMT and Python, I was going through some tutorials and I got stuck on a particular tutorial (Ocenia 2019 Tutorial on PyGMT). Below is the complete code that I am trying to run on Jupyter Notebook:

# Example 3: Oceania 2019 Tutorial for PyGMT...continued

import pygmt

# Digital Elevation Model Map in Color

# Let's have a go at making a map of Oceania showing the ocean bathymetry and land elevation. 

# Create figure
fig=pygmt.Figure()

# We'll start by setting our basemap to focus on the Oceania region (=OC). 
# Our map frame will have tick marks at major and minor intervals (af), 
# and x and y axis labels on the 'W'est and 'S'outh sides only (WSne).

# Creating basic map elements via basemap
fig.basemap(region="=OC", frame=["af", "WSne"])

# GMT6 comes with a global Earth relief model (SRTM15+V2) that can be accessed 
# using special filenames like '@earth_relief_xxx'. Here, we'll plot the 1 arc minute grid
# using fig.grdimage, and explicitly use the 'geo' colormap to colour the terrain.

fig.grdimage(grid="@earth_relief_01m", cmap="geo")

# We'll also add a colorbar for good measure. 
# The position is set to be outside the map frame (J), at the Middle Right (MR) side. 
# The colorbar will automatically pick up the last colormap we used above, 
# but we can force the units to be in kilometres instead of the default metres using cmap="+Uk". 
# We'll also use frame to add annotated tick marks at suitable intervals to the colorbar (af), 
# and set the label to be in units km (+lkm).

fig.colorbar(position="JMR", cmap="+Uk", frame=["af", "y+lkm"])

# Show
fig.show()

# End of code

When I run this code, no image shows up as the tutorial suggests it should, no errors show up. All I see is that the kernel is busy. I have waited upto 20 minutes during a time when internet traffic is low (3 am my time) but nothing happens. I have checked the code with the original tutorial there is no discrepancy.

I ran the code from the jupyter notebook provided in the tutorial, I get the same issue described above.
It appears the program gets into some sort of issue when executing

fig.grdimage(grid="@earth_relief_01m", cmap="geo")

Any help will be much appreciated.
I wanted to thank the GMT group for GMT 6 and PyGMT and for writing a clear installation guide. I was able to install PyGMT and GMT6 without any problems.

Thanks,
Deep

Hi @deep, could you try running grdimage with debugging turned on? Not sure if it’s just a temporary server issue, or something else (the 01 arc minute earth relief grid is quite a big file). Just do:

fig.grdimage(grid="@earth_relief_01m", cmap="geo", V="d")

and show us the output. Also, you could try to get a lower resolution grid (e.g. `@earth_relief_02m") and see if the same problem persists.

Oh, and by the way, that FOSS4G 2019 Oceania tutorial uses a slightly older/different version of pygmt, and there are some python functions in Tutorial 2 & 3 (blockmedian and grdimage on RGB grids) that will require you to pip install https://github.com/GenericMappingTools/pygmt/archive/foss4g2019oceania.zip instead of master.

Hi @weiji14,
Thank you for your response. I will install the suggestion for the Oceania tutorial. Perhaps one day there will be a 2 day online PyGMT/GMT tutorial for Beginners :slight_smile:
The output is rather large so I am sending it in chunks as I could not upload a text file with the information. Almost 1000 lines of stuff came pouring out!

fig.grdimage(grid="@earth_relief_01m", cmap="geo", V="d")

It is rather large and won’t fit in the online editor.

Deleted multiline output 1

Part 2 of output deleted

Output 3 deleted and a zip file is uploaded

Part 4 of output deleted zip file of entire output uploaded

You can zip it and attach the zip

grdimage with debugger.zip (6.3 KB)
Attached is the zip file with the output. I tried other resolutions and I got a figure for until a resolution of 5m. After that I am having the problem I originally posted.
Thanks @Joaquim for giving me the zip tip :slight_smile:

Thanks,

Deep

Hmm, it’s taking a long time for me as well for the 01m grid when running grdimage on the Oceania =OC region (last chunk of error message below):

grdimage [DEBUG]: Found file /home/jovyan/.gmt/server/earth_relief_01m.grd
grdimage [DEBUG]: Look for file earth_relief_01m.grd in /home/jovyan/.gmt
grdimage [DEBUG]: Look for file earth_relief_01m.grd in /home/jovyan/.gmt/cache
grdimage [DEBUG]: Look for file earth_relief_01m.grd in /home/jovyan/.gmt/server
grdimage [DEBUG]: Found file /home/jovyan/.gmt/server/earth_relief_01m.grd
grdimage [DEBUG]: Object ID 0 : Registered Grid File earth_relief_01m.grd as an Input resource with geometry Surface [n_objects = 1]
grdimage [DEBUG]: api_begin_io: Input resource access is now enabled [container]
grdimage [DEBUG]: api_import_grid: Passed ID = 0 and mode = 1
grdimage [DEBUG]: Look for file earth_relief_01m.grd in /home/jovyan/.gmt
grdimage [DEBUG]: Look for file earth_relief_01m.grd in /home/jovyan/.gmt/cache
grdimage [DEBUG]: Look for file earth_relief_01m.grd in /home/jovyan/.gmt/server
grdimage [DEBUG]: Found file /home/jovyan/.gmt/server/earth_relief_01m.grd
grdimage [DEBUG]: Found file /home/jovyan/.gmt/server/earth_relief_01m.grd
grdimage [DEBUG]: Geographic input grid, longitudes span exactly 360
grdimage [DEBUG]: GMT_End_IO: Input resource access is now disabled
grdimage [WARNING]: Spherical approximation used!
grdimage [WARNING]: Central meridian not given, default to 190.91
grdimage [DEBUG]: Projected values in meters: -1.04622e+07 1.04622e+07 -6.12873e+06 3.15813e+06
grdimage [INFORMATION]: Map scale is 1394.96 km per cm or 1:1.39496e+08.
grdimage [DEBUG]: Running in PS mode modern
grdimage [DEBUG]: Use PS filename /home/jovyan/.gmt/sessions/gmt6.151/gmt_5.ps-
grdimage [DEBUG]: Append to hidden PS file /home/jovyan/.gmt/sessions/gmt6.151/gmt_5.ps-
grdimage [DEBUG]: Got session name as pygmt-session and default graphics formats as pdf
grdimage [INFORMATION]: Allocate and read data from file @earth_relief_01m.grd
grdimage [DEBUG]: api_begin_io: Input resource access is now enabled [container]
grdimage [DEBUG]: api_import_grid: Passed ID = 0 and mode = 2
grdimage [INFORMATION]: Reading grid from file earth_relief_01m.grd
grdimage [DEBUG]: processing at most 0 (0x2) chunks at a time (0.0 MiB)...

It works if you change the country code to somewhere else (e.g. AU, BR, CA, etc). Might be something wrong with processing continent-scale images (e.g. =AS, =OC, =EU, etc). This doesn’t seem like a server/internet connection issue since I’ve got a cached image, something to do with how grdimage is processing things?