Skip to content

Commit

Permalink
Refactor 'GeoTIFFWriter.save_image'
Browse files Browse the repository at this point in the history
  • Loading branch information
mraspaud committed Nov 24, 2021
1 parent 7320f15 commit a99dd99
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions satpy/writers/geotiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,7 @@ def save_image(self, img, filename=None, dtype=None, fill_value=None,
"""
filename = filename or self.get_filename(**img.data.attrs)

# Update global GDAL options with these specific ones
gdal_options = self.gdal_options.copy()
for k in kwargs:
if k in self.GDAL_OPTIONS:
gdal_options[k] = kwargs[k]
gdal_options = self._get_gdal_options(kwargs)
if fill_value is None:
# fall back to fill_value from configuration file
fill_value = self.info.get('fill_value')
Expand Down Expand Up @@ -237,3 +233,11 @@ def save_image(self, img, filename=None, dtype=None, fill_value=None,
overviews_resampling=overviews_resampling,
overviews_minsize=overviews_minsize,
**gdal_options)

def _get_gdal_options(self, kwargs):
# Update global GDAL options with these specific ones
gdal_options = self.gdal_options.copy()
for k in kwargs:
if k in self.GDAL_OPTIONS:
gdal_options[k] = kwargs[k]
return gdal_options

0 comments on commit a99dd99

Please sign in to comment.