-
Notifications
You must be signed in to change notification settings - Fork 238
Figure.savefig: Add the 'worldfile' parameter to write a companion world file for raster images #2766
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: Add the 'worldfile' parameter to write a companion world file for raster images #2766
Changes from 1 commit
797e5c6
a36cef7
0c4c9d3
184d5b1
3139130
20e79db
6062666
57c020f
e50ab6d
da5c6d2
a863132
316e5df
2c149bb
1784a2f
9dc40fc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
…rld file
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -252,7 +252,14 @@ def psconvert(self, **kwargs): | |
| ) | ||
|
|
||
| def savefig( | ||
| self, fname, transparent=False, crop=True, anti_alias=True, show=False, **kwargs | ||
| self, | ||
| fname, | ||
| transparent=False, | ||
| crop=True, | ||
| anti_alias=True, | ||
| show=False, | ||
| worldfile=False, | ||
| **kwargs, | ||
| ): | ||
| """ | ||
| Save the figure to a file. | ||
|
|
@@ -291,6 +298,14 @@ def savefig( | |
| vector graphics. | ||
| show: bool | ||
| If ``True``, will open the figure in an external viewer. | ||
| worldfile: bool | ||
| If ``True``, will create a companion | ||
| `world file <https://en.wikipedia.org/wiki/World_file>`__ for the | ||
| figure. The world file will have the same name as the figure file | ||
| but with different extension. See | ||
seisman marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| https://en.wikipedia.org/wiki/World_file#Filename_extension | ||
| for the convention of world file extensions. | ||
| This parameter does not work for KML and GeoTIFF formats. | ||
| dpi : int | ||
| Set raster resolution in dpi [Default is ``720`` for PDF, ``300`` | ||
| for others]. | ||
|
|
@@ -340,6 +355,13 @@ def savefig( | |
| kwargs["Qt"] = 2 | ||
| kwargs["Qg"] = 2 | ||
|
|
||
| if worldfile: | ||
| if ext in ["kml", "tiff"]: | ||
|
||
| raise GMTInvalidInput( | ||
| f"World file is not supported for '{ext}' format." | ||
seisman marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ) | ||
| kwargs["W"] = True | ||
|
|
||
| self.psconvert(prefix=prefix, fmt=fmt, crop=crop, **kwargs) | ||
|
|
||
| # Remove the .pgw world file if exists | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.