plot GEOTIFFs using grdimage

Added by Andreas 10 months ago

Hi all,

I am using 5.4.0_r17381 and try to plot a global GEOTIFF file as a background image. In particular I used the Blue Marble GEOTIFFs available here: https://neo.sci.gsfc.nasa.gov/view.php?datasetId=BlueMarbleNG-TB.

Depending on the chosen projection and the utilized parameters I get some strange results.

For example (all example outputs are attached):
grdimage -JN0/10c -B0 -N -D BlueMarbleNG-TB_2004-08-01_rgb_1440x720.TIFF > jn0.ps

works as expected, while the image is clipped if lon0 is changed:
grdimage -J90/10c -B0 -N -D BlueMarbleNG-TB_2004-08-01_rgb_1440x720.TIFF > jn90.ps

Using an orthographic projections gives the following behaviour: Setting the projection center to 0/0 gives a completely distorted result (consisting just of horizontal stripes):
grdimage -JG0/0/10c -B0 -N -D BlueMarbleNG-TB_2004-08-01_rgb_1440x720.TIFF > jg0.ps,

while only half of the image is displayed correctly if lon0 is changed to a value different from 0:
grdimage -JG90/0/10c -B0 -N -D BlueMarbleNG-TB_2004-08-01_rgb_1440x720.TIFF > jg90.ps

By the way, I observe a similar behaviour when using the corresponding png file in combination with -Dr and -Rd.

Has anyone successfully used grdimage for plotting GEOTIFFS or is there any known issue? Any help is appreciated.

Thanks a lot,

Andreas

jg0.ps (26.1 KB)

jg90.ps (1.61 MB)

jn0.ps (1.99 MB)

jn90.ps (2.24 MB)


Replies (44)

RE: plot GEOTIFFs using grdimage - Added by Paul 10 months ago

Thanks for these Andreas. Turned out we have forgotten to set a grdtype variable when reading an image and thus the entire decision on wrapping around failed. Try r19488 trunk, your cases works for me now.

RE: plot GEOTIFFs using grdimage - Added by Andreas 10 months ago

Thanks for fixing it that fast. Works perfectly now.

RE: plot GEOTIFFs using grdimage - Added by Andreas 6 months ago

Hi all,

I have to raise this topic once more. Although everything is working fine now when using geotiff-images, the issue is still present when using non-georeferenced images (i.e. using -R and -Dr). For example, using a corresponding png-file as follows:

grdimage -JG0/0/10c -B0 -N -Dr -Rd BlueMarbleNG-TB_2004-08-01_rgb_1440x720.PNG > jg0_png.ps

still gives the same corrupted results as described im my original post (see attachment). Now I am running GMT 6.0.0_r19493.

Has something been overlooked when the issue was fixed for geotiff-images?

Many thanks,

Andreas

jg0_png.ps (25.9 KB)

RE: plot GEOTIFFs using grdimage - Added by Joaquim 6 months ago

This is a projection dependent issue. -JR10 or -JH0/10 work fine but -JH1/10 screws already.

RE: plot GEOTIFFs using grdimage - Added by Andreas 6 months ago

Joaquim wrote:

This is a projection dependent issue. -JR10 or -JH0/10 work fine but -JH1/10 screws already.

Does this mean that there is no fix for this issue? It was also a projection dependent issue for geotiff files prior to the first fix (see my original post).

Andreas

RE: plot GEOTIFFs using grdimage - Added by Joaquim 6 months ago

Well, there is no fix in the sense that it's still bugged but should be fixable.

RE: plot GEOTIFFs using grdimage - Added by Paul 6 months ago

Perhaps this is similar to the original fix in that the image is read but not flagged to be geographic given -R -J?

RE: plot GEOTIFFs using grdimage - Added by Joaquim 6 months ago

Yes, likely (or better, hopefully). Had not time to look more.

RE: plot GEOTIFFs using grdimage - Added by Paul 6 months ago

Right, so we needed to reset the grdtype parameter for the image after we apply the -R when -Dr is used. Should be fixed in r19946.

RE: plot GEOTIFFs using grdimage - Added by Andreas 6 months ago

Thanks Paul. This seems to be the right direction. The results looks much better now, although certain pixels are not displayed properly (depending on the chosen projection).

jg0_png.ps (1.73 MB)

RE: plot GEOTIFFs using grdimage - Added by Joaquim 6 months ago

That is strange. Don't know how you gt the png file but I downloaded (save image as) a 1440x720 jpg image and the result does not show those bad pixels at all. Also, my ps file is 547 kb whilst yours is 1.72 Mb.

RE: plot GEOTIFFs using grdimage - Added by Paul 6 months ago

Size of the PS could be related to compression settings (LZEW versus ZIP)?

RE: plot GEOTIFFs using grdimage - Added by Andreas 6 months ago

I got the png file from the website given in the original post, selected the 1440x720 png image and used "save image as". I did the same for the jpg version, like Joaquim did. The result is the same, showing those strange pixels. Also the image size is comparable. I used ZLIP's deflate (PS_IMAGE_COMPRESS=deflate,5) and tested it on two different machines (both running different versions of Ubuntu Linux).

RE: plot GEOTIFFs using grdimage - Added by Joaquim 6 months ago

Is this in a Winbuntu system?

RE: plot GEOTIFFs using grdimage - Added by Joaquim 6 months ago

Can't be that either. I resurrected my Winbuntu build and it still works fine.

RE: plot GEOTIFFs using grdimage - Added by Andreas 6 months ago

No, I tested it on two stand-alone Ubuntu installations (14.04LTS and 16.04LTS). Can I provide any other information about my setup which may help to solve the issue?

RE: plot GEOTIFFs using grdimage - Added by Joaquim 6 months ago

Have no idea why what may be causing this different behavior.

RE: plot GEOTIFFs using grdimage - Added by Paul 6 months ago

There is a history of ubuntu-supplied GMT executables doing odd things, and we always suspected too aggressive compiler options. I realize you are building from trunk but are you selecting release build, debug build, custom compiler switches? Maybe try to build with debug (which lessens the optimization) and see if there is a difference.

RE: plot GEOTIFFs using grdimage - Added by Paul 6 months ago

Sorry, looking more carefully at this I see what you mean: Lots of tiny lines/dots in black that are especially visible over the snow covered areas, yes? I can confirm I get those too. Joaquim, you don't see those?

RE: plot GEOTIFFs using grdimage - Added by Joaquim 6 months ago

Nope, no snow of pixels here. And the file size was a mistake of mine. I first tried with a smaller image and next with the 1440x720 but Windows kept saying the size of first file.

RE: plot GEOTIFFs using grdimage - Added by Andreas 6 months ago

I recompiled with debug (CFLAGS = '-std=gnu99 -g'), but the result did not change. Many gray pixels are visible all over the plot (see the attached screenshot of a zoom to Antarctica).

RE: plot GEOTIFFs using grdimage - Added by Joaquim 6 months ago

Winbuntu build in release mode. No snow in Antarctica.

Capture.JPG (58.3 KB)

RE: plot GEOTIFFs using grdimage - Added by Andreas 6 months ago

Strange! In general, no snow in Antarctica is really bad, but in this special case I would like to have it without snow.

Would it make sense to compare our configuration in more detail (e.g. compare the cmake output)?

RE: plot GEOTIFFs using grdimage - Added by Joaquim 6 months ago

It can't be the compiler because both my MSVC and gcc builds give the same thing. Here's my cmake/gcc output.
  • Options:
  • Found GSHHG database : /mnt/c/progs_cygw/GMTdev/gmt5/trunk/share/coast (2.3.7)
  • Found DCW-GMT database : /mnt/c/progs_cygw/GMTdev/gmt5/trunk/share/dcw
  • Found GMT data server : http://www.soest.hawaii.edu/gmt/data
  • NetCDF library : /usr/lib/x86_64-linux-gnu/libnetcdf.so
  • NetCDF include dir : /usr/include
  • Curl library : /usr/lib/x86_64-linux-gnu/libcurl.so
  • Curl include dir : /usr/include
  • GDAL library : /usr/lib/libgdal.so
  • GDAL include dir : /usr/include/gdal
  • FFTW library : /usr/lib/x86_64-linux-gnu/libfftw3f.so
  • FFTW include dir : /usr/include
  • Accelerate Framework :
  • Regex support : PCRE (/usr/lib/x86_64-linux-gnu/libpcre.so)
  • ZLIB library :
  • ZLIB include dir : /usr/include
  • LAPACK library : yes
  • BLAS library : yes
  • License restriction : no
  • Triangulation method : Shewchuk
  • OpenMP support : enabled
  • GLIB GTHREAD support :
  • PTHREAD support : enabled
  • Build mode : shared
  • Build GMT core : always [libgmt.so]
  • Build PSL library : always [libpostscriptlight.so]
  • Build GMT supplements : yes [supplements.so]
  • Build GMT for developers : yes
  • Build proto supplements : none
– Using CFLAGS = '-std=gnu99 fopenmp -O3 -DNDEBUG'
-
Could NOT find Sphinx (missing: SPHINX_EXECUTABLE)

RE: plot GEOTIFFs using grdimage - Added by Paul 6 months ago

So that is different in grdimage between getting a geotiff (either D or -Dr works well) versus the plain PNG (-Dr works but snows, -D silently produces garbage - it should at least recognize mismatch between header>wesn and projection). Both are read by GDAL but there must be some subtle hidden header parameters that are set differently,.

1 2 (1-25/44)