【发布时间】:2021-05-12 08:38:17
【问题描述】:
我有非常大的 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.
【问题讨论】:
-
嗯,可能“最简单”的方法是添加一些 RAM?您拥有的 RAM 大小是多少?你能退出一些其他程序来释放更多的内存空间吗?
标签: python raster ram geopandas geotiff