Pyspatialml icon indicating copy to clipboard operation
Pyspatialml copied to clipboard

Mask function using an humongous amount of memory

Open willieseun opened this issue 2 years ago • 2 comments

I tried to mask a tif file of 6gb on a pc of 64gb ram and the memory usage kept increasing till it reached about 97% then I cancelled it. I cancelled it because I had similar issues with another file that I didn't cancel and it brought a blue screen error. I hope it can be fixed soon because I tried masking the same image in R studio with the raster, terra package and had no memory problems.

Secondly, the resample function only allows for raster shape, How can I resample with cell size instead?

willieseun avatar Jul 28 '22 14:07 willieseun

Ah, yes the mask function is really just using rasterio's mask method, which reads everything into memory and does require quite a lot of RAM for the processing. The only thing that it does to reduce the memory footprint is it applies the mask by band, which was a quick and dirty approach to masking, assuming that the operation for a single band can still be performed in memory. It should be possible to mask by reading in chunks of the data - will have to look at implementing this.

stevenpawley avatar Jul 29 '22 16:07 stevenpawley

Thanks for your response Steve! Would love you to look at the resampling with cell size too or using a similar .tif template

willieseun avatar Aug 01 '22 08:08 willieseun