Use more universally recognised extensions for world files

This commit is contained in:
AlisterH 2022-11-15 19:14:24 +13:00 committed by GitHub
parent 1c201278ac
commit 41d38250be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -100,7 +100,11 @@ class ExtractProjection(GdalAlgorithm):
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:
@ -116,7 +120,7 @@ class ExtractProjection(GdalAlgorithm):
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])
@ -127,6 +131,6 @@ class ExtractProjection(GdalAlgorithm):
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