gmt icon indicating copy to clipboard operation
gmt copied to clipboard

grdimage plot RGB data

Open ES20180816 opened this issue 3 years ago • 9 comments

Hello everyone,

When I try to use "grdimage" to plot RGB image, every channel can be plotted correctly. However, when plot all three channels simultaneously , there will be a wrong output, as:

-------------------------

grdmix [WARNING]: The geographical metadata for you image will be lost unless you use TIF grdimage [ERROR]: gmt_img_project: Input image does not have sufficient (2) padding

-------------------------

GMT version: 6.3.0 on windows platform

How to solve this problem?

ES20180816 avatar Aug 14 '22 12:08 ES20180816

👋 Thanks for opening your first issue here! Please make sure you filled out the template with as much detail as possible. We appreciate that you took the time to contribute!

Please make sure you read our Contributing Guide and abide by our Code of Conduct.

welcome[bot] avatar Aug 14 '22 12:08 welcome[bot]

Can you make available a small example data and script that illustrates the problem? I cannot guess what kind of wrong output you get, but I see the error message.

PaulWessel avatar Aug 14 '22 12:08 PaulWessel

Can you make available a small example data and script that illustrates the problem? I cannot guess what kind of wrong output you get, but I see the error message.

Of course. The used scripts as : R=10.521676/10.5822904/-0.82758134/-0.70832374 J=M0/0/10c gmt begin Result_plots png E600 gmt basemap -R$R -J$J -Byaf -BWESN

  1. each channel gmt grdimage -R$R -J$J Mabounie_Pauli_R.grd -Q gmt grdimage -R$R -J$J Mabounie_Pauli_G.grd -Q gmt grdimage -R$R -J$J Mabounie_Pauli_B.grd -Q
  2. All three channels gmt grdimage -R$R -J$J Mabounie_Pauli_R.grd Mabounie_Pauli_G.grd Mabounie_Pauli_B.grd -Q

gmt end

Example data: You can find the example data in this link: https://drive.google.com/drive/folders/17VUdxlUlwlu9DZR-8RGmZfOiYbXlmBFU?usp=sharing

Thanks a lot.

ES20180816 avatar Aug 14 '22 12:08 ES20180816

Hi @ES20180816

  • The data link doesn't work.
  • Quite likely this is an use error. Should have used the forum instead of opening a non-reproducible issue

joa-quim avatar Aug 14 '22 22:08 joa-quim

Hi @ES20180816

  • The data link doesn't work.
  • Quite likely this is an use error. Should have used the forum instead of opening a non-reproducible issue

Hi joa-quim,

In order to see the example data, can copy this link and open it in a new window.

In addition, do you mean I used a incorrect script? However, while plotting each channel for this sample data or all three RGB channels for other sample data, this script can work well. And I did not found a solution for this problem in this forum.

Thank you.

ES20180816 avatar Aug 15 '22 20:08 ES20180816

  • The data link doesn't work.

That's where the link is pointing to

https://github.com/GenericMappingTools/gmt/issues/url

I didn't mean that a solution already exists in the forum, but rather that doubts are discussed in the forum, preferably to open issues.

You are using grdimage to access bands. That used to be possible (still should be though) but we now recommend grdmix, but mostly this is now hardly necessary. The best is to use an image format directly.

Anyway, without a file to test, it's hard to provide further help.

joa-quim avatar Aug 15 '22 21:08 joa-quim

  • The data link doesn't work.

That's where the link is pointing to

https://github.com/GenericMappingTools/gmt/issues/url

I didn't mean that a solution already exists in the forum, but rather that doubts are discussed in the forum, preferably to open issues.

You are using grdimage to access bands. That used to be possible (still should be though) but we now recommend grdmix, but mostly this is now hardly necessary. The best is to use an image format directly.

Anyway, without a file to test, it's hard to provide further help.

Sorry, my bad. The data is available in the google drive with this link : https://drive.google.com/drive/folders/17VUdxlUlwlu9DZR-8RGmZfOiYbXlmBFU

You are using grdimage to access bands. That used to be possible (still should be though) but we now recommend grdmix, but mostly this is now hardly necessary. The best is to use an image format directly.

About this problem, I tried to use an image format directly, but I have not found a method to combine the three channels of RGB into one image file.

Thanks a lot for your suggestion

ES20180816 avatar Aug 15 '22 21:08 ES20180816

OK, there seem to to be several issues (bugs) uncovered by this case. I can reproduce the padding issue.

gmt grdimage -JM12 Mabounie_Pauli_R.grd Mabounie_Pauli_G.grd Mabounie_Pauli_B.grd -fg -png lixo
grdmix [WARNING]: The geographical metadata for your image will be lost unless you use TIF
grdimage [ERROR]: gmt_img_project: Input image does not have sufficient (2) padding

Note, using -JX12d/0d will complain but works works

gmt grdimage -JX12d/0d Mabounie_Pauli_R.grd Mabounie_Pauli_G.grd Mabounie_Pauli_B.grd -fg -tif lixo
grdmix [WARNING]: The geographical metadata for your image will be lost unless you use TIF

grdmix works but screws the coordinates. You'll have to use some GDAL tool (e.g. gdal_translate) to restore them

gmt grdmix Mabounie_Pauli_R.grd Mabounie_Pauli_G.grd Mabounie_Pauli_B.grd -Glixo.tif -C -Ni

EDIT: ... and on Windows you got GMTMEX for free. No need to use the old grdwrite2

joa-quim avatar Aug 15 '22 22:08 joa-quim

OK, there seem to to be several issues (bugs) uncovered by this case. I can reproduce the padding issue.

gmt grdimage -JM12 Mabounie_Pauli_R.grd Mabounie_Pauli_G.grd Mabounie_Pauli_B.grd -fg -png lixo
grdmix [WARNING]: The geographical metadata for your image will be lost unless you use TIF
grdimage [ERROR]: gmt_img_project: Input image does not have sufficient (2) padding

Note, using -JX12d/0d will complain but works works

gmt grdimage -JX12d/0d Mabounie_Pauli_R.grd Mabounie_Pauli_G.grd Mabounie_Pauli_B.grd -fg -tif lixo
grdmix [WARNING]: The geographical metadata for your image will be lost unless you use TIF

grdmix works but screws the coordinates. You'll have to use some GDAL tool (e.g. gdal_translate) to restore them

gmt grdmix Mabounie_Pauli_R.grd Mabounie_Pauli_G.grd Mabounie_Pauli_B.grd -Glixo.tif -C -Ni

EDIT: ... and on Windows you got GMTMEX for free. No need to use the old grdwrite2

Dear joa-quim,

By using the -JX projecting parameters, it can work well. Thanks a lot for your advice and help.

Best wishes.

ES20180816 avatar Aug 16 '22 08:08 ES20180816