一方面:conda install gdal成功
另一个方面:Unofficial Windows Binaries for Python Extension Packages下载python对应版本的GDAL,我的python3.9版本的,下载如下
pip install GDAL-3.3.2-cp39-cp39-win-amd64.whl安装成功
import gdal仍然出问题:
Python 3.9.6 (default, Aug 18 2021, 15:44:49) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import gdal
Traceback (most recent call last):
File "", line 1, in
ModuleNotFoundError: No module named 'gdal'
奇怪了,怎么回事
突然发现 from osgeo import gdal没问题,那以后只能这么用了
解决方案:把import gdal改成:
from osgeo import gdal
2.Ubuntu怎么办,试了好久 没用,之前安装成功过,不记得了,现在一直失败,求高手指点,现在用的改用其他方法:
具体方法:
在windows下,将tif转mat
import scipy.io as sio
import skimage.io
img = skimage.io.imread(image_sets[i])
# 转为mat
sio.savemat("GaoChun_GF1_20210808_NNDiffu_train1.mat", {'image': img})
在wnidows和ubuntu下,读取mat文件比较简单:
data = sio.loadmat('./Data/Matlab_data_format.mat')