Is there an -i option for plot -Z?

I’m trying to color a multisegment line with a CPT according to the point’s z-value. My data looks like this:

                      z-values              lat     lon
                          |                  |       |
                          V                  V       V
1620802958 3C65D9 DLH008 650 142 -110.605 50.0381 8.55761 2880 5024 A
1620802959 3C65D9 DLH008 650 142 -110.605 50.0381 8.55761 2880 5024 A
1620802959 3C65D9 DLH008 750 141 -110.748 50.0377 8.5559 2880 5024 A
…

I tried plot flight.txt -i7,6 -W+z -Zflight.txt but only got an error as my z-values aren’t in the last colum as required per plot -Z documenation. Is there something similar to the -i option for plot -Z I’m missing?

Thank you for your help!

Sorry, violation of the GMT record directive: All numerical columns first, then all trailing text. Your 3C65… etc starts the trailing text.

awk ‘{print($8,$7,$4)}’ …

Hi @pwessel I’m not sure I understand your point: When I use plot flight.txt -i7,6 -W1p,red everything works as expected. Z-values are treated as trailing text?

Hi @thwbecker – I hoped to get around rearranging the columns (in total about 856 GB worth of data). But your awk snippet does the trick nicely on my test data set. Thank you.

I see GMT converts your columns 2 and 3 to NaN so you are able to use -i7,6. OK, I suspect a bug since -Z is relatively recent and I bet there is interference with -i. We have seen that before and addressed it but probably not here. Might you be able to produce a command plus a Z file that uses the three lines above in an attempt to do your plot and that gives that error?

I should have made some example code available right away. My apologies, @pwessel. Here is a bare bones version:

gmt begin deps_eddf png
  gmt plot -R007:30/010:00/49:30/50:50 \
    -JL008:34:13.64/50:01:59.90/49:57/50:23/15c -B \ 
    flight.txt -i7,6 -W1p,red
gmt end show

flight.zip (3.2 KB) contains the required flight.txt

This works as expected. I get a red line on the plot.

Now for what I’m trying to achieve: Column 3 (when you start counting at 0) contains my z-values, in this case altitude information. I want to color the plotted line according to altitude with a CPT. In my understanding this can be done with -W+z -Zflight.txt -Cbuda. But only if the supplied file has the z-values in the last column:

Alternatively, give the name of a file with one z-value (read from the last column) for each polygon in the input data.

(source)

So recycling my data file fails predictably:

gmt begin deps_eddf png
  gmt plot -R007:30/010:00/49:30/50:50 \
    -JL008:34:13.64/50:01:59.90/49:57/50:23/15c -B \
    flight.txt -i7,6 -W+z -Zflight.txt -Cbuda
gmt end show

This code seems to wait for input which never comes and needs to be terminated.

I tried -i7,6,3 as a moonshot but got no luck:

plot [WARNING]: Number of input columns required [2] is less that implied by -i [3]

I assume this is the polygon plotting machinery complaining.

It all boils down to the question: Is there a way to get those z-values from my original data without preparing a separate file for -Z?

I have around 4700 tracks to plot adding up to about 856 GB of ASCII-data. Or would you say it is more efficient to crunch the data into specialized files?

A workaround for now is to make a copy of flight.txt, say flight2.txt and use that in -Z and then it works. I will debug why it wont release that pointer…You are using the same file for two different inputs and for some reason that hangs.

Thank you for looking into this @pwessel!