Topics

Best way to sample all data in a raster


himat15@...
 

I have a large raster file, and I want to visualize it. But opening it as a dataset causes my program to crash due to running out of memory.

Since my only purpose is to visualize the data, the data I get can just be a subsample of the overall data (imagine taking every other pixel).

Is there a built-in way to do this though while reading the dataset, or do I have to separately generate the list of (x,y) coordinates I want in an alternating fashion, and then pass that to  rasterio.sample.sample_gen? https://rasterio.readthedocs.io/en/latest/api/rasterio.sample.html

Is there no way to directly read a random or alternating sample of the data from a direct dataset.read() call?


Alan Snow
 

I believe that this is what you are looking for: https://rasterio.readthedocs.io/en/latest/topics/resampling.html