Skip to content

Commit

Permalink
Use more universally recognised extensions for world files
Browse files Browse the repository at this point in the history
  • Loading branch information
AlisterH committed Nov 15, 2022
1 parent 1c20127 commit 41d3825
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions python/plugins/processing/algs/gdal/extractprojection.py
Expand Up @@ -100,7 +100,11 @@ def processAlgorithm(self, parameters, context, feedback):
raster = None
rasterDS = None

outFileName = os.path.splitext(str(rasterPath))[0]
inFileName = os.path.splitext(str(rasterPath))
outFileName = inFileName[0]
# this is not a good idea as it won't work with an extension like .jpeg
# outFileExt = '.' + inFileName[1][1:4:2] + 'w'
outFileExt = inFileName[1][0:2] + inFileName[1][-1] + 'w'

results = {}
if crs != '' and createPrj:
Expand All @@ -116,7 +120,7 @@ def processAlgorithm(self, parameters, context, feedback):
else:
results[self.PRJ_FILE] = None

with open(outFileName + '.wld', 'wt') as wld:
with open(outFileName + outFileExt, 'wt') as wld:
wld.write('%0.8f\n' % geotransform[1])
wld.write('%0.8f\n' % geotransform[4])
wld.write('%0.8f\n' % geotransform[2])
Expand All @@ -127,6 +131,6 @@ def processAlgorithm(self, parameters, context, feedback):
wld.write('%0.8f\n' % (geotransform[3]
+ 0.5 * geotransform[4]
+ 0.5 * geotransform[5]))
results[self.WORLD_FILE] = outFileName + '.wld'
results[self.WORLD_FILE] = outFileName + outFileExt

return results

0 comments on commit 41d3825

Please sign in to comment.