从google earth引擎中提取给定位置的landsat地表反射率时间序列

geextract的Python项目详细描述


google earth引擎数据提取工具。快速获取用于探索性分析和算法测试的陆地卫星多光谱时间序列

在线文档可在https://loicdtx.github.io/landsat-extract-gee

https://coveralls.io/repos/github/loicdtx/landsat-extract-gee/badge.svg?branch=masterhttps://travis-ci.org/loicdtx/landsat-extract-gee.svg?branch=masterhttps://badge.fury.io/py/geextract.svg

简介

从google earth引擎平台提取landsat时间序列的python库(api+命令行)。可以查询多边形上的单个像素或空间聚合值。通过命令行使用时,提取的时间序列将写入sqlite数据库。

其目的是为探索性分析或算法测试提供对陆地卫星时间序列的快速访问。与其下载整个陆地卫星场景堆栈、在本地准备数据并提取感兴趣的时间序列(可能需要几天时间),geextract允许在几秒钟内获取时间序列。

与Python2.7和3兼容。

用法

api

api的主要功能是ts_extract

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)

命令行

geextract带有两个命令行,用于直接从命令行提取陆地卫星时间序列。

  • gee_extract.py:提取单个站点的陆地卫星多光谱时间序列。提取的数据将自动添加到sqlite数据库中。
  • gee_extract_batch.py:批量订购多地点陆地卫星多光谱时间序列。
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
https://github.com/loicdtx/landsat-extract-gee/raw/master/docs/figs/multispectral_uxmal.png

安装

您必须有一个Google Earth Engine帐户才能使用包。

然后,在虚拟环境中运行:

pip install geextract
earthengine authenticate

这将在您的浏览器中打开一个google身份验证页面,并给您一个身份验证令牌粘贴回终端。

您可以通过运行来检查身份验证过程是否成功。

python -c "import ee; ee.Initialize()"

如果什么都没发生…那就行了。

基准

提取速度的快速基准,使用500米缓冲区。

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'

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java使用prepared语句在oracle中插入日期   对点具有双重值的java   使用多个通配符的java请求映射   java Springboot为什么要设置springbootstartertomcat   除了对JavaBean的请求之外,还使用servletContext的servlet   java如何清除OCSID。返回到池的连接时的CLIENTID JDBC客户端信息属性   将整型数组转换为光栅Java   java使用对象引用作为互斥锁   java为什么在编程语言中使用sin函数返回奇怪的sin值不像计算器   java如何将JButton链接到对象并调用相关方法   php用Java发送POST数据   导航属性的java模拟加载   java多个活动错误Android试图对空对象引用调用虚拟方法“”   java Android更改ActionBar文本颜色   如何使用带有java反射且不带开关的parant引用创建子类