- gee的python运行环境,需要运行下面的几个命令,但是第二个安装一直失败,后来发现conda可以安装,于是基于miniconda安装了一个python3.6虚拟环境,并安装了所需要的库。第一个和第三个使用pip安装,第二个使用conda安装。
pip install google-api-python-client
conda install pyCrypto
pip install earthengine-api
-
用到的miniconda的地址为:
https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda3-4.7.10-Windows-x86_64.exe -
本文制作好的虚拟环境链接:https://pan.baidu.com/s/1YcBfFtzPQW6Ag-X8DLY-qg 提取码:emg0
-
下载解压后放到miniconda或anaconda的安装目录的envs文件夹下,使用conda activate gee激活环境,输入earthengine authenticate进行下一步操作。弹出浏览器页面按照提示,复制授权码,粘贴到命令行并回车。出现Successfully saved authorization token表示授权成功。
-
运行示例代码,获取下载链接
from __future__ import print_function
import ee
#import ee.mapclient
ee.Initialize()
# Get a download URL for an image.
image1 = ee.Image('CGIAR/SRTM90_V4')
path = image1.getDownloadUrl({
'scale': 30,
'crs': 'EPSG:4326',
'region': '[[-120, 35], [-119, 35], [-119, 34], [-120, 34]]'
})
print(path)
- 运行时报错
TimeoutError: [WinError 10060] 由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。
,后来搜到了很多比如关闭防火墙,修改hosts文件这些,都没用,最后参考https://zhuanlan.zhihu.com/p/50717864解决,方法为在命令行输入,下面的命令,地址为自己的代理地址,需要注意的是这种设置代理方式只能针对当前窗口有效
set http_proxy=http://127.0.0.1:50482
set https_proxy=http://127.0.0.1:50482
- 最后再次运行代码,获取到了数据的下载链接
- 参考无形的风的教程 https://zhuanlan.zhihu.com/p/40319581
- 环境包含的库详情
Package Version
------------------------ -------------------
cachetools 4.0.0
certifi 2019.11.28
chardet 3.0.4
earthengine-api 0.1.210
future 0.18.2
google-api-core 1.15.0
google-api-python-client 1.7.11
google-auth 1.10.0
google-auth-httplib2 0.0.3
google-cloud-core 1.1.0
google-cloud-storage 1.24.1
google-resumable-media 0.5.0
googleapis-common-protos 1.6.0
httplib2 0.15.0
idna 2.8
pip 19.3.1
protobuf 3.11.2
pyasn1 0.4.8
pyasn1-modules 0.2.8
pycrypto 2.6.1
pytz 2019.3
requests 2.22.0
rsa 4.0
setuptools 44.0.0.post20200106
six 1.13.0
uritemplate 3.0.1
urllib3 1.25.7
wheel 0.33.6
wincertstore 0.2