搜索和下载哥白尼哨兵卫星图像的实用程序
sentinelsat的Python项目详细描述
哨兵
sentinelsat搜索、下载和检索Sentinel的元数据 卫星图像来自 Copernicus Open Access Hub简单。
它提供了一个易于使用的命令行界面
sentinelsat -u <user> -p <password> -g <search_polygon.geojson> --sentinel 2 --cloud 30
以及强大的python api。
fromsentinelsatimportSentinelAPI,read_geojson,geojson_to_wktapi=SentinelAPI('user','password')footprint=geojson_to_wkt(read_geojson('search_polygon.geojson'))products=api.query(footprint,producttype='SLC',orbitdirection='ASCENDING')api.download_all(products)
安装
通过pip安装sentinelsat:
pip install sentinelsat
用法
sentinelsat提供了一个python api和一个用于搜索的命令行界面, 下载并检索Sentinel产品的元数据。
python库
fromsentinelsat.sentinelimportSentinelAPI,read_geojson,geojson_to_wktfromdatetimeimportdate# connect to the APIapi=SentinelAPI('user','password','https://scihub.copernicus.eu/dhus')# download single scene by known product idapi.download(<product_id>)# search by polygon, time, and Hub query keywordsfootprint=geojson_to_wkt(read_geojson('map.geojson'))products=api.query(footprint,date=('20151219',date(2015,12,29)),platformname='Sentinel-2',cloudcoverpercentage=(0,30))# download all results from the searchapi.download_all(products)# GeoJSON FeatureCollection containing footprints and metadata of the scenesapi.to_geojson(products)# GeoPandas GeoDataFrame with the metadata of the scenes and the footprints as geometriesapi.to_geodataframe(products)# Get basic information about the product: its title, file size, MD5 sum, date, footprint and# its download urlapi.get_product_odata(<product_id>)# Get the product's full metadata available on the serverapi.get_product_odata(<product_id>,full=True)
可以在Copernicus Open Access Hub documentation中找到有效的搜索查询关键字。
命令行界面
基本搜索查询包括搜索区域几何图形以及用户名和 访问哥白尼开放访问中心的密码。
sentinelsat -u <user> -p <password> -g <geojson>
搜索区域作为geojson文件提供,可以使用 QGIS或geojson.io。 如果不指定开始日期和结束日期,则只指定上次发布的产品 24小时查询。
示例
按降序搜索并下载SLC类型的所有Sentinel-1场景 轨道,2015年。
sentinelsat -u <user> -p <password> -g <search_polygon.geojson> -s 20150101 -e 20151231 -d \ --producttype SLC -q "orbitdirection=Descending"\ --url "https://scihub.copernicus.eu/dhus"
也可以通过环境变量设置用户名、密码和dhus url,以方便使用。
# same result as query above exportDHUS_USER="<user>"exportDHUS_PASSWORD="<password>"exportDHUS_URL="https://scihub.copernicus.eu/dhus" sentinelsat -g <search_polygon.geojson> -s 20150101 -e 20151231 -d \ --producttype SLC -q "orbitdirection=Descending"
选项
-u | –user | TEXT | Username [required] (or environment variable DHUS_USER) |
-p | –password | TEXT | Password [required] (or environment variable DHUS_PASSWORD) |
–url | TEXT | Define another API URL. Default URL is ‘https://scihub.copernicus.eu/apihub/’. | |
-s | –start | TEXT | Start date of the query in the format YYYYMMDD. |
-e | –end | TEXT | End date of the query in the format YYYYMMDD. |
-g | –geometry | PATH | Search area geometry as GeoJSON file. |
–uuid | TEXT | Select a specific product UUID instead of a query. Multiple UUIDs can separated by commas. | |
–name | TEXT | Select specific product(s) by filename. Supports wildcards. | |
–sentinel | INT | Limit search to a Sentinel satellite (constellation). | |
–instrument | TEXT | Limit search to a specific instrument on a Sentinel satellite. | |
–producttype | TEXT | Limit search to a Sentinel product type. | |
-c | –cloud | INT | Maximum cloud cover in percent. (requires –sentinel to be 2 or 3) |
-o | –order-by | TEXT | Comma-separated list of keywords to order the result by. Prefix ‘-‘ for descending order. |
-l | –limit | INT | Maximum number of results to return. Defaults to no limit. |
-d | –download | Download all results of the query. | |
–path | PATH | Set the path where the files will be saved. | |
-q | –query | TEXT | Extra search keywords you want to use in the query. Separate keywords with comma. Example: ‘producttype=GRD,polarisationmode=HH’. |
-f | –footprints | Create geojson file search_footprints.geojson with footprints of the query result. | |
–version | Show version number and exit. | ||
-h | –help | Show help message and exit. |
测试
在sentinelsat:
上运行测试git clone https://github.com/sentinelsat/sentinelsat.git cd sentinelsat pip install -e .[dev] py.test -v
默认情况下,对哥白尼开放访问中心查询的预先记录的响应不受其停机时间的影响。 要允许测试对哥白尼开放访问中心运行实际查询,请设置环境变量
exportDHUS_USER=<username> exportDHUS_PASSWORD=<password>
并将--vcr disable添加到py.test参数中。 要更新录制,请使用--vcr record_new或--vcr reset。
文档
构建文档:
git clone https://github.com/sentinelsat/sentinelsat.git cd sentinelsat pip install -e .[dev]cd docs make html
完整的文档也发布在http://sentinelsat.readthedocs.io/。
更改日志
见CHANGELOG。您还可以使用github的compare视图查看changes in the master branch since last release。
贡献者
我们邀请任何人通过参与代码、报告错误、修复错误、编写文档和教程以及讨论这个项目的未来来参与。请检查CONTRIBUTE.rst。有关维护者和贡献者的列表,请参见AUTHORS.rst和contributor graph。
许可证
gplv3+