Geographic Information Systems Asked on June 29, 2021
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?
xarray leaves the files open unless you call close
.
You can read more about it here: http://xarray.pydata.org/en/stable/io.html
The file_cache_maxsize
option is also useful to know about: http://xarray.pydata.org/en/stable/generated/xarray.set_options.html
Answered by snowman2 on June 29, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP