I wanted to able to delete a temporary file, after opening it with rioxarray and start to process the final product.
I followed two ideas:
a)
with rioxarray.open_rasterio(temp_file) as raster:
# do processing
# save output
os.remove(file)
b)
raster = rioxarray.open_rasterio(temp_file)
# do processing
# save result somewhere
del raster
gc.collect()
os.remove(file)
Both didn't work because, the file was still opened. How can this temporary file be deleted?