Deciphering the Documentation and writing a tutorial (edited)

Hallo GMT group.

I am gradually getting the hang of the GMT syntax. I am grateful for your patience with me. The forum text editor keeps breaking my formatting, sorry. M.J.

(I have edited this post several times before clicking the commit button as I continue to cross reference the documentation. Please bear with some of my ignorance.)

Here, I read a 3600px by 1800px Plate-Carree png and reproject it to Orthographic over Cardiff.

gmt grdimage -JG+03/51/5 -Rd basic.png -png cardiff-JG-5

The image looks as I expect. Display SmileyFace !! Yay !

Scale set to 1 gives a 118 px square image ? What scale does that ?

Scale set to 5 gives a 591 px square image ?

I cannot work out the units GMT is working with here.

Is it pixels per centimeter? Is scale looking for centimetres ?

(I'm just coming right out and saying this is weird)

(unless GMT is focused on print media, in which case it's very logical)

The JG perspective options are a bit troublesome. I get nonsence results or errors.

As I add one by one the options described in the documentation, I try to work out the expected range of inputs without success.

This projection example is from the university of Hawaii GMT page:


I break it down here:

-Jg|G (upper/lower case indicates the type of scale to print?)

<lon0>=degrees (0 to 360 | -180 to 0 to +180)

/<lat0>=degrees (-90 to +90)

/<scl>|<width> unknown format | unknown units

[+a<azimuth>] Degrees (0 to 360 or other ?)

[+t<tilt>] (0 to 90 or 0 to 180 yaw? roll? pitch?)

[+v<vwidth> (unknown units unknown function) / <vheight>]

(is this oblique "/" a typo? is it meant to be "|" )

(or is it meant to be a ratio? W/H ? what's the point of that ?)

(what is vertical width? )

[+w<twist>] (degrees ? roll)

[+z<altitude> (unknown units earth-radii ? Km ? )

[r|R]|g] (still working on this one)

I have been poring over the docs but there is a dearth of examples with accompanying illustrations.

Documentation source:

I may have neglected to explain the project... sorry.

I am an historian working as an archivist but I also write code that amateur astronomy people use. I am upgrading scripts that convert JPL images to Plate-Carre format so they can be used in 3D image rendering apps. (PovRay, Blender, xPlanet, etc.) These scripts currently rely on MMPS, ImageMagick, Bash, and some other Linux commands. I want to use components that are more precise, cross platform, and are compatable with a variety of graphical user interfaces (probably wrapped in Python). Gdal is an option but seems to have a flaw in rendering a complete Equidistant Cylidrical projection from perspective or orthographic image sources. I am now exploring GMT's capabilities. I am not a G.I.S. professional so I am going to make many mistakes interpreting industry jargon and translating to traditional, imaging, or celestial terms.

I believe in the Feynman hypothisis that only the ability to teach a topic indicates true understanding, so I will be composing a tutorial of my own for the use by my intended audience. For this reason I may ask astonishingly naiive questions such as "Do ESRI numbers refer to ellipsoids and geoids and projections?" etc.

Although I may occasionally sound stu[pid, I am not. I am one of the forum moderators at xplanet and I wrote the TravellerWorldViewer web application. I know, not much.

anyway, that's why I'm here, why I'm involved, and why I will be asking questions as I zoom through the documentation.

Morfydd James (Molly)

Like I mentioned in the other answer, please post a reproducible example. And two other things

Thank you Joaquim,

I have been studying documentation from several sources including the official ones at this domain. I cited the U.Hawaii page as that one had the example.

I am restricted to version 6.3.0 as that is the one available to my inteded audience. They will be using the gmt package provided by the ubuntu/debian repositories.

My tests:

Molly’s GMT test: Input basic.png is 3600x1800 plate-carre Earth

gmt grdimage -JG+5/+50/20 -Rd basic.png -png map_JG-5
(Successful 20cm orthographic image centered on Cardiff ! Yay !)

gmt grdimage -JG+5/+50/20 +a30 +t5 +v1 +w0 +z5 -Rd basic.png -png map_JG-5

gmt [ERROR]: Cannot run a one-liner modern command within an existing modern mode session

Do I need to “Clear” something ?

From the man page:
-Jg|G lon0 / lat0 / scl | width [+a azimuth ] [+t tilt ] [+v vwidth / vheight ] [+w twist ] [+z altitude [r|R]|g] (General Perspective)

Question one -- Is it manditory that the perspective parameters be within a gmt script ? Is it impossible to output a specific view with one line of code?
Question two -- Does gmt have an inverse projection function? Can I reproject from ortho back to plate-carree ?

Thank you again for your patience. As I build up a set of working examples, I will be able to use them as templates for further trial and error study. This will be essential for the tutorial for my imaging scripts.

And no errors between first and second grdimage commands?

Yes. Need to do gmt clear sessions. But this is only necessary when a previous error left behind and non-finished session.

The old docs show that? New show


-Jg|Glon0/lat0 /scale|width[+aazimuth][+ttilt][+vvwidth/vheight][+wtwist][+zaltitude[r|R]|g]

i.e., the GMT golden rule no spaces inside option strings

Yes, they are called one-liners and you used them (docs explain it)

The official answer is no. One need to make the tour proj1 → geog → proj2 but it’s actually not impossible that we can. Since PROJ created the pipelines we can go directly from proj1 -> proj2 and since we accept proj strings in GMT it is not impossible that it can be done, but I never tried. Note that here I’m talking only in image reprojections, not map-making that has different issues.

Now this is bad, really bad. See, we spend 3 years fixing and improving things and next users, not rarely, come asking for help for things that … have been fixed meanwhile. Manipulating images in GMT is one of those cases.

Thank you Joaquim.

What does the correct command look like ?

No spaces inside the -J option

gmt grdimage -JG5/50/20+a30+t5+v1+w0+z5 -Rd basic.png -png map_JG-5

1 Like