From 41767a26027f3f5802f0370572ce936deb408952 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Fri, 22 Sep 2023 13:23:22 +0800 Subject: [PATCH 01/15] Figure.savefig: Support generating GeoTIFF file (with extension '.tiff') --- pygmt/figure.py | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/pygmt/figure.py b/pygmt/figure.py index f8b631e7102..a511855f3b7 100644 --- a/pygmt/figure.py +++ b/pygmt/figure.py @@ -257,12 +257,19 @@ def savefig( """ Save the figure to a file. - This method implements a matplotlib-like interface for - :meth:`pygmt.Figure.psconvert`. + Supported file formats and their extensions: - Supported formats: PNG (``.png``), JPEG (``.jpg`` or ``.jpeg``), - PDF (``.pdf``), BMP (``.bmp``), TIFF (``.tif``), EPS (``.eps``), and - KML (``.kml``). The KML output generates a companion PNG file. + - PNG (``.png``) + - JPEG (``.jpg`` or ``.jpeg``) + - PDF (``.pdf``) + - BMP (``.bmp``) + - TIFF (``.tif`` or `.tiff`) + - EPS (``.eps``) + - KML (``.kml``) + + For TIFF format, ``.tiff`` generates a GeoTIFF file with embedded + georeferencing information and a companion world file. For KML format, + a companion PNG file is also generated. You can pass in any keyword arguments that :meth:`pygmt.Figure.psconvert` accepts. @@ -279,8 +286,8 @@ def savefig( If ``True``, will crop the figure canvas (page) to the plot area. anti_alias: bool If ``True``, will use anti-aliasing when creating raster images - (PNG, JPG, TIFF). More specifically, it passes arguments ``t2`` - and ``g2`` to the ``anti_aliasing`` parameter of + (BMP, PNG, JPEG and TIFF). More specifically, it passes arguments + ``t2`` and ``g2`` to the ``anti_aliasing`` parameter of :meth:`pygmt.Figure.psconvert`. Ignored if creating vector graphics. show: bool @@ -307,9 +314,14 @@ def savefig( fname = Path(fname) prefix, suffix = fname.with_suffix("").as_posix(), fname.suffix ext = suffix[1:].lower() # Remove the . and normalize to lowercase - # alias jpeg to jpg - if ext == "jpeg": + + if ext == "jpeg": # Alias jpeg to jpg ext = "jpg" + elif ext == "tiff": # Alias tif to tiff and make it a GeoTIFF + ext = "tif" + kwargs["W"] = "+g" + elif ext == "kml": + kwargs["W"] = "+k" if ext not in fmts: if ext == "ps": @@ -328,8 +340,6 @@ def savefig( if anti_alias: kwargs["Qt"] = 2 kwargs["Qg"] = 2 - if ext == "kml": - kwargs["W"] = "+k" self.psconvert(prefix=prefix, fmt=fmt, crop=crop, **kwargs) From cd9918fe42de4238b96ba0797504bf9fa7f03d36 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Fri, 22 Sep 2023 13:35:16 +0800 Subject: [PATCH 02/15] Test the .tiff extension --- pygmt/tests/test_figure.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/tests/test_figure.py b/pygmt/tests/test_figure.py index f01df85f942..b7b97ed507f 100644 --- a/pygmt/tests/test_figure.py +++ b/pygmt/tests/test_figure.py @@ -83,7 +83,7 @@ def test_figure_savefig_exists(): fig = Figure() fig.basemap(region="10/70/-300/800", projection="X3i/5i", frame="af") prefix = "test_figure_savefig_exists" - for fmt in "png pdf jpg jpeg bmp eps tif PNG JPG JPEG Png".split(): + for fmt in "png pdf jpg jpeg bmp eps tif tiff PNG JPG JPEG Png".split(): fname = ".".join([prefix, fmt]) fig.savefig(fname) From f2348ccb68642e0ac9b0c7ae7361af3b3753a36b Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Fri, 22 Sep 2023 22:44:07 +0800 Subject: [PATCH 03/15] GeoTIFF doesn't need the -T option --- pygmt/figure.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pygmt/figure.py b/pygmt/figure.py index a511855f3b7..65cc6432ef3 100644 --- a/pygmt/figure.py +++ b/pygmt/figure.py @@ -308,6 +308,7 @@ def savefig( "bmp": "b", "eps": "e", "tif": "t", + "tiff": None, # GeoTIFF doesn't need the -T option "kml": "g", } @@ -317,10 +318,9 @@ def savefig( if ext == "jpeg": # Alias jpeg to jpg ext = "jpg" - elif ext == "tiff": # Alias tif to tiff and make it a GeoTIFF - ext = "tif" + elif ext == "tiff": # GeoTIFF kwargs["W"] = "+g" - elif ext == "kml": + elif ext == "kml": # KML kwargs["W"] = "+k" if ext not in fmts: From 921912d842c5414c37aa8f592b70afdd96a5d2a0 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Fri, 22 Sep 2023 23:01:50 +0800 Subject: [PATCH 04/15] Add a new test to check if .tiff is a GeoTIFF file --- pygmt/tests/test_figure.py | 40 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/pygmt/tests/test_figure.py b/pygmt/tests/test_figure.py index b7b97ed507f..5a8c5c390ed 100644 --- a/pygmt/tests/test_figure.py +++ b/pygmt/tests/test_figure.py @@ -92,6 +92,46 @@ def test_figure_savefig_exists(): fname.unlink() +def test_figure_savefig_geotiff(): + """ + Make sure the extension .tiff generates a GeoTIFF file. + """ + fig = Figure() + fig.basemap(region=[0, 10, 0, 10], projection="M10c", frame=True) + + # save as GeoTIFF + geofname = Path("test_figure_savefig_geotiff.tiff") + fig.savefig(geofname) + + assert geofname.exists() + # Is a GeoTIFF file + try: + import rioxarray + + with rioxarray.open_rasterio(geofname) as xds: + assert xds.rio.crs is not None + except ImportError: + pass + geofname.unlink() + + # save as TIFF + fname = Path("test_figure_savefig_geotiff.tif") + fig.savefig(fname) + assert fname.exists() + # Is a normal TIFF file + try: + import rioxarray + from rasterio.errors import NotGeoreferencedWarning + + with pytest.warns(expected_warning=NotGeoreferencedWarning) as record: + with rioxarray.open_rasterio(fname) as xds: + assert xds.rio.crs is None + assert len(record) == 1 + except ImportError: + pass + fname.unlink() + + def test_figure_savefig_directory_nonexists(): """ Make sure that Figure.savefig() raises a FileNotFoundError when the parent From a83862f14c897471032f457ce7ba485453f04c9b Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Fri, 22 Sep 2023 23:21:16 +0800 Subject: [PATCH 05/15] Revert the changes in test_figure_savefig_exists --- pygmt/tests/test_figure.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/tests/test_figure.py b/pygmt/tests/test_figure.py index 5a8c5c390ed..a0d3fafbc8b 100644 --- a/pygmt/tests/test_figure.py +++ b/pygmt/tests/test_figure.py @@ -83,7 +83,7 @@ def test_figure_savefig_exists(): fig = Figure() fig.basemap(region="10/70/-300/800", projection="X3i/5i", frame="af") prefix = "test_figure_savefig_exists" - for fmt in "png pdf jpg jpeg bmp eps tif tiff PNG JPG JPEG Png".split(): + for fmt in "png pdf jpg jpeg bmp eps tif PNG JPG JPEG Png".split(): fname = ".".join([prefix, fmt]) fig.savefig(fname) From 51c8dbe6cc66cb942ebb6b201d2a72e750d13201 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Fri, 22 Sep 2023 23:27:29 +0800 Subject: [PATCH 06/15] Simplify the test --- pygmt/tests/test_figure.py | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/pygmt/tests/test_figure.py b/pygmt/tests/test_figure.py index a0d3fafbc8b..cb01ffbbbb4 100644 --- a/pygmt/tests/test_figure.py +++ b/pygmt/tests/test_figure.py @@ -94,7 +94,8 @@ def test_figure_savefig_exists(): def test_figure_savefig_geotiff(): """ - Make sure the extension .tiff generates a GeoTIFF file. + Make sure .tif generates a normal TIFF file and .tiff generates a GeoTIFF + file. """ fig = Figure() fig.basemap(region=[0, 10, 0, 10], projection="M10c", frame=True) @@ -102,33 +103,31 @@ def test_figure_savefig_geotiff(): # save as GeoTIFF geofname = Path("test_figure_savefig_geotiff.tiff") fig.savefig(geofname) - assert geofname.exists() - # Is a GeoTIFF file - try: - import rioxarray + assert geofname.with_suffix(".pgw").exists() # The companion world file - with rioxarray.open_rasterio(geofname) as xds: - assert xds.rio.crs is not None - except ImportError: - pass - geofname.unlink() - - # save as TIFF + # Save as TIFF fname = Path("test_figure_savefig_geotiff.tif") fig.savefig(fname) assert fname.exists() - # Is a normal TIFF file + + # Check is a TIFF is georeferenced or not try: import rioxarray from rasterio.errors import NotGeoreferencedWarning + # GeoTIFF + with rioxarray.open_rasterio(geofname) as xds: + assert xds.rio.crs is not None + # TIFF with pytest.warns(expected_warning=NotGeoreferencedWarning) as record: with rioxarray.open_rasterio(fname) as xds: assert xds.rio.crs is None assert len(record) == 1 except ImportError: pass + geofname.unlink() + geofname.with_suffix(".pgw").unlink() fname.unlink() From cf771cc8c4459174be118711e3e8d5b9a810e959 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Fri, 22 Sep 2023 23:32:20 +0800 Subject: [PATCH 07/15] Fix a linting issue --- pygmt/tests/test_figure.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pygmt/tests/test_figure.py b/pygmt/tests/test_figure.py index cb01ffbbbb4..e1706c311a0 100644 --- a/pygmt/tests/test_figure.py +++ b/pygmt/tests/test_figure.py @@ -113,6 +113,7 @@ def test_figure_savefig_geotiff(): # Check is a TIFF is georeferenced or not try: + # pylint: disable=import-outside-toplevel import rioxarray from rasterio.errors import NotGeoreferencedWarning From 3303ba4ce139f1cf14c39638a0f3f9dd1b7978c5 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Sun, 24 Sep 2023 17:56:43 +0800 Subject: [PATCH 08/15] Fix typos MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Yvonne Fröhlich <94163266+yvonnefroehlich@users.noreply.github.com> --- pygmt/figure.py | 10 +++++----- pygmt/tests/test_figure.py | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pygmt/figure.py b/pygmt/figure.py index 65cc6432ef3..47a52405014 100644 --- a/pygmt/figure.py +++ b/pygmt/figure.py @@ -263,7 +263,7 @@ def savefig( - JPEG (``.jpg`` or ``.jpeg``) - PDF (``.pdf``) - BMP (``.bmp``) - - TIFF (``.tif`` or `.tiff`) + - TIFF (``.tif`` or ``.tiff``) - EPS (``.eps``) - KML (``.kml``) @@ -286,10 +286,10 @@ def savefig( If ``True``, will crop the figure canvas (page) to the plot area. anti_alias: bool If ``True``, will use anti-aliasing when creating raster images - (BMP, PNG, JPEG and TIFF). More specifically, it passes arguments - ``t2`` and ``g2`` to the ``anti_aliasing`` parameter of - :meth:`pygmt.Figure.psconvert`. Ignored if creating vector - graphics. + (BMP, PNG, JPEG, and TIFF). More specifically, it passes the + arguments ``"t2"`` and ``"g2"`` to the ``anti_aliasing`` + parameter of :meth:`pygmt.Figure.psconvert`. Ignored if + creating vector graphics. show: bool If ``True``, will open the figure in an external viewer. dpi : int diff --git a/pygmt/tests/test_figure.py b/pygmt/tests/test_figure.py index e1706c311a0..89ab04508b8 100644 --- a/pygmt/tests/test_figure.py +++ b/pygmt/tests/test_figure.py @@ -100,7 +100,7 @@ def test_figure_savefig_geotiff(): fig = Figure() fig.basemap(region=[0, 10, 0, 10], projection="M10c", frame=True) - # save as GeoTIFF + # Save as GeoTIFF geofname = Path("test_figure_savefig_geotiff.tiff") fig.savefig(geofname) assert geofname.exists() @@ -111,7 +111,7 @@ def test_figure_savefig_geotiff(): fig.savefig(fname) assert fname.exists() - # Check is a TIFF is georeferenced or not + # Check if a TIFF is georeferenced or not try: # pylint: disable=import-outside-toplevel import rioxarray From 4fd2f50c874c5b09cb09539c1fe745123dbac296 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Mon, 25 Sep 2023 07:38:25 +0800 Subject: [PATCH 09/15] Apply suggestions from code review Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com> --- pygmt/figure.py | 3 ++- pygmt/tests/test_figure.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pygmt/figure.py b/pygmt/figure.py index 47a52405014..fa739293a6c 100644 --- a/pygmt/figure.py +++ b/pygmt/figure.py @@ -263,7 +263,8 @@ def savefig( - JPEG (``.jpg`` or ``.jpeg``) - PDF (``.pdf``) - BMP (``.bmp``) - - TIFF (``.tif`` or ``.tiff``) + - TIFF (``.tif``) + - GeoTIFF (``.tiff``) - EPS (``.eps``) - KML (``.kml``) diff --git a/pygmt/tests/test_figure.py b/pygmt/tests/test_figure.py index 89ab04508b8..0341bdc3060 100644 --- a/pygmt/tests/test_figure.py +++ b/pygmt/tests/test_figure.py @@ -107,7 +107,7 @@ def test_figure_savefig_geotiff(): assert geofname.with_suffix(".pgw").exists() # The companion world file # Save as TIFF - fname = Path("test_figure_savefig_geotiff.tif") + fname = Path("test_figure_savefig_tiff.tif") fig.savefig(fname) assert fname.exists() From 252514b429577d952807fb516e4826280ef9816e Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Wed, 4 Oct 2023 17:39:55 +0800 Subject: [PATCH 10/15] Delete the .pgw if exists --- pygmt/figure.py | 17 ++++++++++------- pygmt/tests/test_figure.py | 4 ++-- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/pygmt/figure.py b/pygmt/figure.py index fa739293a6c..5c4217ed00d 100644 --- a/pygmt/figure.py +++ b/pygmt/figure.py @@ -268,9 +268,7 @@ def savefig( - EPS (``.eps``) - KML (``.kml``) - For TIFF format, ``.tiff`` generates a GeoTIFF file with embedded - georeferencing information and a companion world file. For KML format, - a companion PNG file is also generated. + For KML format, a companion PNG file is also generated. You can pass in any keyword arguments that :meth:`pygmt.Figure.psconvert` accepts. @@ -287,10 +285,10 @@ def savefig( If ``True``, will crop the figure canvas (page) to the plot area. anti_alias: bool If ``True``, will use anti-aliasing when creating raster images - (BMP, PNG, JPEG, and TIFF). More specifically, it passes the - arguments ``"t2"`` and ``"g2"`` to the ``anti_aliasing`` - parameter of :meth:`pygmt.Figure.psconvert`. Ignored if - creating vector graphics. + (BMP, PNG, JPEG, TIFF, and GeoTIFF). More specifically, it passes + the arguments ``"t2"`` and ``"g2"`` to the ``anti_aliasing`` + parameter of :meth:`pygmt.Figure.psconvert`. Ignored if creating + vector graphics. show: bool If ``True``, will open the figure in an external viewer. dpi : int @@ -344,6 +342,11 @@ def savefig( self.psconvert(prefix=prefix, fmt=fmt, crop=crop, **kwargs) + # Remove the .pgw world file if exists + # See upstream fix https://github.com/GenericMappingTools/gmt/pull/7865 + if ext == "tiff" and fname.with_suffix(".pgw").exists(): + fname.with_suffix(".pgw").unlink() + # Rename if file extension doesn't match the input file suffix if ext != suffix[1:]: fname.with_suffix("." + ext).rename(fname) diff --git a/pygmt/tests/test_figure.py b/pygmt/tests/test_figure.py index 0341bdc3060..2b5df7060e3 100644 --- a/pygmt/tests/test_figure.py +++ b/pygmt/tests/test_figure.py @@ -104,7 +104,8 @@ def test_figure_savefig_geotiff(): geofname = Path("test_figure_savefig_geotiff.tiff") fig.savefig(geofname) assert geofname.exists() - assert geofname.with_suffix(".pgw").exists() # The companion world file + # The .pgw should not exist + assert not geofname.with_suffix(".pgw").exists() # Save as TIFF fname = Path("test_figure_savefig_tiff.tif") @@ -128,7 +129,6 @@ def test_figure_savefig_geotiff(): except ImportError: pass geofname.unlink() - geofname.with_suffix(".pgw").unlink() fname.unlink() From 44bfcfe93a286a8d26906d217bffe594df3bd5b5 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Mon, 9 Oct 2023 10:10:27 +0800 Subject: [PATCH 11/15] Improve the comment about removing .pgw file Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com> --- pygmt/figure.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pygmt/figure.py b/pygmt/figure.py index 5c4217ed00d..23b0b2e6272 100644 --- a/pygmt/figure.py +++ b/pygmt/figure.py @@ -342,7 +342,8 @@ def savefig( self.psconvert(prefix=prefix, fmt=fmt, crop=crop, **kwargs) - # Remove the .pgw world file if exists + # Remove the .pgw world file if exists + # Not necessary after GMT 6.5.0. # See upstream fix https://github.com/GenericMappingTools/gmt/pull/7865 if ext == "tiff" and fname.with_suffix(".pgw").exists(): fname.with_suffix(".pgw").unlink() From e7c2b36cd87812ce7b061f6302a8718917d48ad8 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Mon, 9 Oct 2023 14:55:54 +0800 Subject: [PATCH 12/15] Check bounds in the test Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com> --- pygmt/tests/test_figure.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pygmt/tests/test_figure.py b/pygmt/tests/test_figure.py index 2b5df7060e3..53ef898bfd7 100644 --- a/pygmt/tests/test_figure.py +++ b/pygmt/tests/test_figure.py @@ -121,10 +121,24 @@ def test_figure_savefig_geotiff(): # GeoTIFF with rioxarray.open_rasterio(geofname) as xds: assert xds.rio.crs is not None +npt.assert_allclose( + actual=xds.rio.bounds(), + desired=( + -667728.5869475466, + 6356999.491390044, + 594269.0244906943, + 8381540.2498699855, + ), + ) + assert xds.rio.shape == (2149, 1340) # TIFF with pytest.warns(expected_warning=NotGeoreferencedWarning) as record: with rioxarray.open_rasterio(fname) as xds: assert xds.rio.crs is None + npt.assert_allclose( + actual=xds.rio.bounds(), desired=(0.0, 0.0, 1331.0, 1257.0) + ) + assert xds.rio.shape == (1257, 1331) assert len(record) == 1 except ImportError: pass From 26837e84dd532acc22993a6b45cab8f2ede919fc Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Mon, 9 Oct 2023 14:57:05 +0800 Subject: [PATCH 13/15] Fix typos and linting issues --- pygmt/figure.py | 2 +- pygmt/tests/test_figure.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pygmt/figure.py b/pygmt/figure.py index 23b0b2e6272..93e2d70340d 100644 --- a/pygmt/figure.py +++ b/pygmt/figure.py @@ -342,7 +342,7 @@ def savefig( self.psconvert(prefix=prefix, fmt=fmt, crop=crop, **kwargs) - # Remove the .pgw world file if exists + # Remove the .pgw world file if exists # Not necessary after GMT 6.5.0. # See upstream fix https://github.com/GenericMappingTools/gmt/pull/7865 if ext == "tiff" and fname.with_suffix(".pgw").exists(): diff --git a/pygmt/tests/test_figure.py b/pygmt/tests/test_figure.py index 53ef898bfd7..35a406d7ea4 100644 --- a/pygmt/tests/test_figure.py +++ b/pygmt/tests/test_figure.py @@ -121,7 +121,7 @@ def test_figure_savefig_geotiff(): # GeoTIFF with rioxarray.open_rasterio(geofname) as xds: assert xds.rio.crs is not None -npt.assert_allclose( + npt.assert_allclose( actual=xds.rio.bounds(), desired=( -667728.5869475466, From 71611dfd617c870cd3bdaf0ff84b07213427befd Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Wed, 18 Oct 2023 14:26:30 +0800 Subject: [PATCH 14/15] Fix the bounds and shape for geotiff files --- pygmt/tests/test_figure.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pygmt/tests/test_figure.py b/pygmt/tests/test_figure.py index 35a406d7ea4..814f13335d7 100644 --- a/pygmt/tests/test_figure.py +++ b/pygmt/tests/test_figure.py @@ -124,13 +124,13 @@ def test_figure_savefig_geotiff(): npt.assert_allclose( actual=xds.rio.bounds(), desired=( - -667728.5869475466, - 6356999.491390044, - 594269.0244906943, - 8381540.2498699855, + -661136.0621116752, + -54631.82709660966, + 592385.4459661598, + 1129371.7360144067, ), ) - assert xds.rio.shape == (2149, 1340) + assert xds.rio.shape == (1257, 1331) # TIFF with pytest.warns(expected_warning=NotGeoreferencedWarning) as record: with rioxarray.open_rasterio(fname) as xds: From 6a1caa355155e04e7e139ea9e88bac84111eb0a0 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Tue, 24 Oct 2023 21:13:28 +0800 Subject: [PATCH 15/15] Check Affine transformation Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com> --- pygmt/tests/test_figure.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pygmt/tests/test_figure.py b/pygmt/tests/test_figure.py index 814f13335d7..4969aad0fb0 100644 --- a/pygmt/tests/test_figure.py +++ b/pygmt/tests/test_figure.py @@ -117,6 +117,7 @@ def test_figure_savefig_geotiff(): # pylint: disable=import-outside-toplevel import rioxarray from rasterio.errors import NotGeoreferencedWarning + from rasterio.transform import Affine # GeoTIFF with rioxarray.open_rasterio(geofname) as xds: @@ -131,6 +132,14 @@ def test_figure_savefig_geotiff(): ), ) assert xds.rio.shape == (1257, 1331) + assert xds.rio.transform() == Affine( + a=941.789262267344, + b=0.0, + c=-661136.0621116752, + d=0.0, + e=-941.92805338983, + f=1129371.7360144067, + ) # TIFF with pytest.warns(expected_warning=NotGeoreferencedWarning) as record: with rioxarray.open_rasterio(fname) as xds: @@ -139,6 +148,9 @@ def test_figure_savefig_geotiff(): actual=xds.rio.bounds(), desired=(0.0, 0.0, 1331.0, 1257.0) ) assert xds.rio.shape == (1257, 1331) + assert xds.rio.transform() == Affine( + a=1.0, b=0.0, c=0.0, d=0.0, e=1.0, f=0.0 + ) assert len(record) == 1 except ImportError: pass