为什么gdal对MODIS光栅图像返回“无”,如何正确加载?

2024-09-29 07:26:58 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个简单的kmeans示例,我正试图在GoogleColab中使用它,但现在GoogleDrive无法正确加载到我的Geotiff中。我使用gdal的方式是否有问题?谢谢

### mount google drive
from google.colab import drive
from sklearn.cluster import KMeans 
import os
from osgeo import gdal
import numpy as np 

drive.mount('/content/gdrive')
!ls

output: Drive already mounted at /content/gdrive; to attempt to forcibly remount, call drive.mount("/content/gdrive", force_remount=True). gdrive sample_data

### load image
naip_fn = './gdrive/MOD13A1.006__500m_16_days_EVI_doy2021065_aid0001.tif' 
driverTiff = gdal.GetDriverByName('GTiff') 
image = gdal.Open(naip_fn,gdal.GA_ReadOnly) 
print(image)

output: None


Tags: tofromimageimportoutputgoogledrivecontent
1条回答
网友
1楼 · 发布于 2024-09-29 07:26:58

原来这只是谷歌硬盘路径的问题。从Google Drive加载数据时,需要我的硬盘部分,即

naip_fn = './gdrive/My Drive/MOD13A1.006__500m_16_days_EVI_doy2021065_aid0001.tif' 

相关问题 更多 >