Skip to content

[BREAKING] Raise GMTTypeError exception for unsupported image dtypes#4673

Open
seisman wants to merge 1 commit into
GenericMappingTools:mainfrom
seisman:raise-on-unsupported-image-dtype
Open

[BREAKING] Raise GMTTypeError exception for unsupported image dtypes#4673
seisman wants to merge 1 commit into
GenericMappingTools:mainfrom
seisman:raise-on-unsupported-image-dtype

Conversation

@seisman

@seisman seisman commented Jun 12, 2026

Copy link
Copy Markdown
Member

GMT only supports images with the uint8 data type. Previously, GMT would emit the following errors for unsupported image data types but would not stop execution:

Error: e [ERROR]: Using this data type (Int8) is not implemented
grdimage (gmtapi_import_image): Bad measurement unit.  Choose among c|i|p [/tmp/pygmt-6rst4f_m.tif]
[Session pygmt-session (1729)]: Error returned from GMT API: GMT_IMAGE_READ_ERROR (22)
[Session pygmt-session (1729)]: Error returned from GMT API: GMT_IMAGE_READ_ERROR (22)

As a result, unsupported images were still read and plotted, although the output was likely incorrect. PyGMT would then issue a warning about the unsupported data type.

It is unclear when this behavior changed, but the GMT dev version now produces the following error instead (xref: https://github.com/GenericMappingTools/pygmt/actions/runs/27249793607/job/80471539938):

Error: e [ERROR]: Using this data type (Int8) is not implemented
pygmt-session (gmtapi_import_image): Bad measurement unit.  Choose among c|i|p [/tmp/pygmt-87amr_xv.tif]
[Session pygmt-session (1729)]: Error returned from GMT API: GMT_IMAGE_READ_ERROR (22)
[Session pygmt-session (1729)]: Error returned from GMT API: GMT_IMAGE_READ_ERROR (22)
Error: e [ERROR]: Option -R parsing failure. Correct syntax:
...
Error: e [ERROR]: Offending option -R0/0/0/0

Apparently, GMT now fails to read images with unsupported data types altogether, causing our tests to fail. I can't find the exact changes that lead to the behavior changes, but I feel it's likely some changes in GDAL.

This PR addresses the issue by raising a GMTTypeError whenever an unsupported image data type is encountered.

@seisman seisman added enhancement Improving an existing feature needs review This PR has higher priority and needs review. run/test-gmt-dev Trigger the GMT Dev Tests workflow in PR labels Jun 12, 2026
@seisman seisman added this to the 0.19.0 milestone Jun 12, 2026
@seisman seisman changed the title Raise for unsupported image dtypes [BREAKING] Raise GMTTypeError exception for unsupported image dtypes Jun 12, 2026

@weiji14 weiji14 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error only shows up for the GMT dev version right? Not the current stable GMT 6.6.0 release? Ok with raising an error for GMT 6.5 and 6.6 users, since they should really rescale to 0-255 anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Improving an existing feature needs review This PR has higher priority and needs review. run/test-gmt-dev Trigger the GMT Dev Tests workflow in PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants