Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gdal_pansharpen.py: avoid error trying to generate relative path
Browse files Browse the repository at this point in the history
dbaston committed Jul 19, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 852c0a5 commit bef2ba5
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
@@ -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>

0 comments on commit bef2ba5

Please sign in to comment.