从google earth引擎中提取给定位置的landsat地表反射率时间序列
geextract的Python项目详细描述
google earth引擎数据提取工具。快速获取用于探索性分析和算法测试的陆地卫星多光谱时间序列
在线文档可在https://loicdtx.github.io/landsat-extract-gee 从google earth引擎平台提取landsat时间序列的python库(api+命令行)。可以查询多边形上的单个像素或空间聚合值。通过命令行使用时,提取的时间序列将写入sqlite数据库。 其目的是为探索性分析或算法测试提供对陆地卫星时间序列的快速访问。与其下载整个陆地卫星场景堆栈、在本地准备数据并提取感兴趣的时间序列(可能需要几天时间),geextract允许在几秒钟内获取时间序列。 与Python2.7和3兼容。 api的主要功能是ts_extract geextract带有两个命令行,用于直接从命令行提取陆地卫星时间序列。 您必须有一个Google Earth Engine帐户才能使用包。 然后,在虚拟环境中运行: 这将在您的浏览器中打开一个google身份验证页面,并给您一个身份验证令牌粘贴回终端。 您可以通过运行来检查身份验证过程是否成功。 如果什么都没发生…那就行了。 提取速度的快速基准,使用500米缓冲区。简介
用法
api
fromgeextractimportts_extractfromdatetimeimportdatetime# Extract a Landsat 7 time-series for a 500m radius circular buffer around# a location in Yucatanlon=-89.8107197lat=20.4159611LE7_dict_list=ts_extract(lon=lon,lat=lat,sensor='LE7',start=datetime(1999,1,1),radius=500)
命令行
gee_extract.py --help
# Extract all the LT5 bands for a location in Yucatan for the entire Landsat period, with a 500m radius
gee_extract.py -s LT5 -b 1980-01-01 -lon -89.8107 -lat 20.4159 -r 500 -db /tmp/gee_db.sqlite -site uxmal -table col_1
gee_extract.py -s LE7 -b 1980-01-01 -lon -89.8107 -lat 20.4159 -r 500 -db /tmp/gee_db.sqlite -site uxmal -table col_1
gee_extract.py -s LC8 -b 1980-01-01 -lon -89.8107 -lat 20.4159 -r 500 -db /tmp/gee_db.sqlite -site uxmal -table col_1
gee_extract_batch.py --help
# Extract all the LC8 bands in a 500 meters for two locations between 2012 and now
echo"4.7174,44.7814,rompon\n-149.4260,-17.6509,tahiti" > site_list.txt
gee_extract_batch.py site_list.txt -b 1984-01-01 -s LT5 -r 500 -db /tmp/gee_db.sqlite -table landsat_ts
gee_extract_batch.py site_list.txt -b 1984-01-01 -s LE7 -r 500 -db /tmp/gee_db.sqlite -table landsat_ts
gee_extract_batch.py site_list.txt -b 1984-01-01 -s LC8 -r 500 -db /tmp/gee_db.sqlite -table landsat_ts
安装
pip install geextract
earthengine authenticate
python -c "import ee; ee.Initialize()"
基准
importtimefromdatetimeimportdatetimefrompprintimportpprintimportgeextractlon=-89.8107197lat=20.4159611forsensorin['LT5','LE7','LT4','LC8']:start=time.time()out=geextract.ts_extract(lon=lon,lat=lat,sensor=sensor,start=datetime(1980,1,1,0,0),end=datetime.today(),radius=500)end=time.time()pprint('%s. Extracted %d records in %.1f seconds'%(sensor,len(out),end-start))
# 'LT5. Extracted 142 records in 1.9 seconds'
# 'LE7. Extracted 249 records in 5.8 seconds'
# 'LT4. Extracted 7 records in 1.0 seconds'
# 'LC8. Extracted 72 records in 2.4 seconds'
推荐PyPI第三方库