Skip to content

Commit

Permalink
changed tif creation form translate to warp #47
Browse files Browse the repository at this point in the history
  • Loading branch information
FlatErikk committed Jul 23, 2024
1 parent ece0941 commit 968c993
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions framework/climate/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,14 @@ def cache_tif_from_nc(filename_in: str, foldertype: str, temp_doc: TempResultFil
# print(f"filename_out: {filename_out}")
# print(f"filepath_in: {filepath_in}")
# print(f"filepath_out: {filepath_out}")

# Set destination spatial reference
kwargs = {"dstSRS": 'EPSG:4326'}

try:
ds = gdal.Open(filepath_in)
gdal.Translate(filepath_out, ds, format="Gtiff")
# for some reason, tif files created via translate are
# not allways working correctly in our visualization
gdal.Warp(filepath_out, filepath_in, **kwargs)
fileversion_out = os.stat(filepath_out).st_mtime
temp_doc.st_mtime_tif = fileversion_out
temp_doc.save()
Expand Down

0 comments on commit 968c993

Please sign in to comment.