'Writing a MemoryFile() with rio cogeo back to a file on disk
I am not sure why I am struggling with this one but I would appreciate your help. I want to read a geotiff, process with rio cogeo and then save it as the hash of that file. I am doing something odd.... Here is my function. Any ideas?
try:
with MemoryFile() as mem_dst:
dst_profile = cog_profiles.get("deflate")
cog_translate(filepath, mem_dst.name, dst_profile, in_memory=True)
sha1 = hashFile(mem_dst)
with rasterio.open(mem_dst) as src:
with rasterio.open(
f'{output_folder}/{sha1}',
'w',
**src.profile
) as dst:
dst.write(src, 1)
except Exception as e:
print(e)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
