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
Figure.savefig: Support generating GeoTIFF file (with extension '.tiff') #2698
Figure.savefig: Support generating GeoTIFF file (with extension '.tiff') #2698
Changes from 7 commits
41767a2
cd9918f
f2348cc
921912d
a83862f
51c8dbe
cf771cc
3303ba4
4fd2f50
9e77ef3
d5e6617
f1f41bf
252514b
c4d480e
2137682
d57d8e0
44bfcfe
e7c2b36
9127756
26837e8
d5ececc
05ef422
71611df
916b4a8
6a1caa3
da9ca29
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Strange, why is a pgw file generated instead of a tfw file? See https://en.wikipedia.org/wiki/World_file#Filename_extension. A .tif or .tiff file should be linked to .tfw no?
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.
See #2658 (comment) for some tests.
Here, we call
gmt psconvert -A -P -W+g
without specifying the-T
option.Looking at the
psconvert
source code (https://github.com/GenericMappingTools/gmt/blob/master/src/psconvert.c#L1008-L1010),The default format is PNG is
-W+g
is used. I think GMT fist converts PS to lossless PNG, then write the world file, and callsgdal_translate
to combine the PNG and world file into a GeoTIFF file. The extension of the world file is determined from the extension of the raster file (in this case PNG), thus we have apgw
file. This may be an upstream feature or bug.Actually, since we already have a
GeoTIFF
file, the world_file is no longer needed. Maybe we should remove it?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 ok, thanks for the explanation. You're right that we wouldn't need the
pgw
file or any world file anyway since the GeoTIFF should already have the metadata embedded inside.Maybe best to add the code to remove the
pgw
file upstream in GMT when a GeoTIFF is created, or at least renamepgw
totfw
? On the PyGMT side, we could match the upstream implementation with GMT <= 6.4.0.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.
Removing
pgw
makes more sense to me. I'll open an issue report and see what the GMT team thinks about it.Edit: upstream issue report at GenericMappingTools/gmt#7844
Do you mean we should keep the
pgw
file? I'm thinking about adding a new parameterworldfile=True
toFigure.savefig()
which generates a companion world file.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 mean we should match whatever GMT does with the
pgw
world file later in GMT 6.5.0 (e.g. delete thepgw
file), but open up that issue first. Theworldfile=True
parameter sounds nice actually, this would be similar to GDAL'sTFW=YES/NO
option when creating GeoTIFFs - https://gdal.org/drivers/raster/gtiff.html#creation-optionsThere 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.
Note that GenericMappingTools/gmt#7865 was merged, and the upcoming GMT 6.5.0 should delete the
pgw
world file if a GeoTIFF output is requested.