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.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Implement virtualfile_from_image #3468
base: main
Are you sure you want to change the base?
WIP: Implement virtualfile_from_image #3468
Changes from 4 commits
331f9aa
8c63ae6
5cc4cc7
7828153
149d2ae
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
Check warning on line 1646 in pygmt/clib/session.py
Codecov / codecov/patch
pygmt/clib/session.py#L1645-L1646
Check warning on line 1654 in pygmt/clib/session.py
Codecov / codecov/patch
pygmt/clib/session.py#L1654
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.
A little unsure about the dimension order when flattening the 3-D image into a 2-D matrix (hard to decipher from https://docs.generic-mapping-tools.org/6.5/devdocs/api.html#gmt-images). Does GMT expect band sequential (BSQ) order, or something else?
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.
Maybe this issue (GenericMappingTools/gmt#3299) is helpful.
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.
Ah yes, that is very helpful, so Paul said this:
The 'P' in 'TRP' sounds like band interleaved by pixel (BIP) if I'm interpreting this correctly. So something like:
where we go first along row 1 from left-to-right with RGB values of each pixel, and then row 2, row 3, etc.
That said, the format appears to be determined by
API_IMAGE_LAYOUT
, and I tried to get it using the following code:but it comes up empty even though I'm using GMT 6.5.0? There's a note here that mentions
API_IMAGE_LAYOUT
is not defined if GMT is not compiled with GDAL:pygmt/pygmt/clib/session.py
Lines 202 to 207 in f8db417
Unsure what is going on, maybe I should test this out on the branch in #3450. Edit: See #3450 (comment)
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.
From the GMT source codes, it seems the value is set after reading an image via GDAL. More specifically, these lines:
https://github.com/GenericMappingTools/gmt/blob/54dbea3217e45c982d83721ebd2740c84870c637/src/gmt_gdalread.c#L822.
But I still can't get its value even after reading an image. Need more try.
As for reading an image, the layout information can be obtained from
header.mem_layout
, seepygmt/pygmt/datatypes/image.py
Line 62 in f8db417
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.
I'm unsure if this is correct. From the source codes, it seems the default image layout is
TRBa
.https://github.com/GenericMappingTools/gmt/blob/426abad288ef4b87c2cecf4c9633fd849866e45d/src/gmt_constants.h#L322
Check warning on line 1658 in pygmt/clib/session.py
Codecov / codecov/patch
pygmt/clib/session.py#L1656-L1658
Check warning on line 1669 in pygmt/clib/session.py
Codecov / codecov/patch
pygmt/clib/session.py#L1666-L1669