Skip to content

Commit

Permalink
gdal_pansharpen.py: avoid error trying to generate relative path
Browse files Browse the repository at this point in the history
  • Loading branch information
dbaston committed Jul 18, 2023
1 parent b003ce1 commit fb77cbb
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions swig/python/gdal-utils/osgeo_utils/gdal_pansharpen.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,13 @@ def gdal_pansharpen(
ms_name = spectral_ds[i].GetDescription()
if driver_name.upper() == "VRT":
if not os.path.isabs(ms_name):
ms_relative = "1"
ms_name = os.path.relpath(ms_name, os.path.dirname(dst_filename))
try:
ms_name = os.path.relpath(ms_name, os.path.dirname(dst_filename))
ms_relative = "1"
except ValueError:
# Thrown if generating a relative path is not possible, e.g. if
# ms_name is on a different Windows drive from dst_filename
pass

vrt_xml += """ <SpectralBand%s>
<SourceFilename relativeToVRT="%s">%s</SourceFilename>
Expand Down

0 comments on commit fb77cbb

Please sign in to comment.