문제 설명
큰 geotif 파일 열기 (Open large geotif file)
매우 큰 geotif 파일이 있습니다. 하지만 colabs에서는 열 수 없습니다. RAM이 충분하지 않습니다. 그래서 내가 실행할 때마다 충돌이 시작되었습니다. 이 일을 도와줄 사람이 있습니까?
import numpy as np
from rasterio.plot import show
import os
import matplotlib.pyplot as plt
%matplotlib inline
Data dir
data_dir = "data"
Filepath
fp = os.path.join(data_dir, "/content/drive/MyDrive/LINEasia/test2.tif")
Open the raster file in read mode
raster = rasterio.open(fp)
Read NIR channel (channel number 4)
nir = raster.read(1)
Calculate some stats to check the data
print(red.mean())
print(nir.mean())
print(type(nir))
Visualize
show(nir, cmap='terrain')
}```
uncompressed file size around 3GB.
</code></pre>
참조 솔루션
방법 1:
You can work on smaller portions more like windows. Below code reads 400x400 window from (0, 0) point.
with rasterio.open('/content/drive/MyDrive/LINEasia/test2.tif') as f:
w = f.read(1, window=Window(0, 0, 400, 400))
(by supun nayake、Baran Bursalı)
참조 문서