Skip to content

Commit

Permalink
Merge pull request #57 from geofranzi/47-nc-and-tif-climate
Browse files Browse the repository at this point in the history
changed tif creation form translate to warp #47
  • Loading branch information
geofranzi committed Jul 23, 2024
2 parents 08f0747 + 968c993 commit b71087e
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 b71087e

Please sign in to comment.