GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [BREAKING] Raise GMTTypeError exception for unsupported image dtypes by seisman · Pull Request #4673 · GenericMappingTools/pygmt

Conversation

@seisman

@seisman seisman commented Jun 12, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@seisman
Raise for unsupported image dtypes
14d98ed
@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 had a problem deploying to pr-tests June 12, 2026 03:16 — with GitHub Actions Error
@seisman
seisman had a problem deploying to pr-tests June 12, 2026 03:16 — with GitHub Actions Error
@seisman
seisman had a problem deploying to pr-tests June 12, 2026 03:16 — with GitHub Actions Error
@seisman
seisman had a problem deploying to pr-tests June 12, 2026 03:16 — with GitHub Actions Error
@seisman
seisman had a problem deploying to pr-tests June 12, 2026 03:16 — with GitHub Actions Failure
@seisman
seisman had a problem deploying to pr-tests June 12, 2026 03:16 — with GitHub Actions Failure
@seisman
seisman had a problem deploying to pr-tests June 12, 2026 03:16 — with GitHub Actions Failure
@seisman
seisman had a problem deploying to pr-tests June 12, 2026 03:16 — with GitHub Actions Failure
@seisman seisman changed the title Raise for unsupported image dtypes [BREAKING] Raise GMTTypeError exception for unsupported image dtypes Jun 12, 2026
weiji14
weiji14 approved these changes Jun 12, 2026
View reviewed changes

@weiji14 weiji14 left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@seisman

seisman commented Jun 12, 2026

Copy link
Copy Markdown
Member Author

The error only shows up for the GMT dev version right? Not the current stable GMT 6.6.0 release?

The error also shows up for GMT 6.6.0 but GMT can still read it:

>>> import pygmt
>>> image = pygmt.datasets.load_blue_marble()
>>> image = image.astype(dtype="int8")
>>> fig = pygmt.Figure()
>>> fig.grdimage(grid=image)
/home/seisman/OSS/gmt/pygmt/pygmt/helpers/decorators.py:842: RuntimeWarning: Input image has dtype: int8 which is unsupported, and may result in an incorrect output. Please recast image to a uint8 dtype and/or scale to 0-255 range, e.g. using a histogram equalization function like skimage.exposure.equalize_hist.
  return module_func(*args, **kwargs)
grdimage [ERROR]: Using this data type (Int8) is not implemented
grdimage (gmtapi_import_image): Bad measurement unit.  Choose among c|i|p [/tmp/pygmt-vpfsm9ze.tif]
[Session pygmt-session (5)]: Error returned from GMT API: GMT_IMAGE_READ_ERROR (22)
[Session pygmt-session (5)]: Error returned from GMT API: GMT_IMAGE_READ_ERROR (22)
grdimage [ERROR]: Using this data type (Int8) is not implemented
grdimage (gmtapi_import_image): Bad measurement unit.  Choose among c|i|p [/tmp/pygmt-vpfsm9ze.tif]
[Session pygmt-session (5)]: Error returned from GMT API: GMT_IMAGE_READ_ERROR (22)
[Session pygmt-session (5)]: Error returned from GMT API: GMT_IMAGE_READ_ERROR (22)

>>> fig.show()  # The image is incorrectly plotted.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@weiji14

weiji14 commented Jun 12, 2026

Copy link
Copy Markdown
Member

OK. If image is incorrect, then error is good.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@seisman
seisman merged commit 6eea101 into GenericMappingTools:main Jun 12, 2026
31 of 40 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@seisman seisman removed 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

This branch had an error being deployed

1 failed deployment
pr-tests — 14d98edf Deployed Jun 12, 2026 by seisman via ubuntu-24.04-arm - GMT master #10544
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@weiji14 weiji14 weiji14 approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

enhancement Improving an existing feature

Projects

None yet

Milestone

0.19.0

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@seisman @weiji14
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.