Installation
pip install sentinelsat
connect to the API
from sentinelsat import SentinelAPI, read_geojson, geojson_to_wkt
from datetime import date
api = SentinelAPI(‘user’, ‘password’, ‘https://scihub.copernicus.eu/dhus’)
download single scene by known product id
api.download(<product_id>)
search by polygon, time, and SciHub query keywords
footprint = geojson_to_wkt(read_geojson(’/path/to/map.geojson’)) (附言有geojson格式构造例子)
products = api.query(footprint,
date=(‘20151219’, date(2015, 12, 29)),
platformname=‘Sentinel-2’,
cloudcoverpercentage=(0, 30))
download all results from the search
api.download_all(products)
convert to Pandas DataFrame
products_df = api.to_dataframe(products)
GeoJSON FeatureCollection containing footprints and metadata of the scenes
api.to_geojson(products)
GeoPandas GeoDataFrame with the metadata of the scenes and the footprints as geometries
api.to_geodataframe(products)
Get basic information about the product: its title, file size, MD5 sum, date, footprint and
its download url
api.get_product_odata(<product_id>)
Get the product’s full metadata available on the server
api.get_product_odata(<product_id>, full=True)
Download the product’s
if product_info[‘Online’]:
print(‘Product {} is online. Starting download.’.format(<product_id>))
api.download(<product_id>)
else:
print(‘Product {} is not online.’.format(<product_id>))
# Download the product’s
GEOJSON标准格式学习
1.点要素Point
点要素是最简单的,类型type对应Point,然后坐标是一个1维的数组,里面有两个元素(如果是立体的坐标就是三维x,y,z),分别为经度和纬度。properties里面可以封装各种属性,例如名称、标识颜色等等。
例如:
{“type”:“Feature”,
“properties”:{},
“geometry”:{
“type”:“Point”,
“coordinates”:[105.38090375,31.57826438]
}
}
2.线要素
.线要素就是指线段,记录的是线的端点坐标,
{“type”:“Feature”,
“properties”:{},
“geometry”:{
“type”:“LineString”,
“coordinates”:[[105.60859305,30.651556287],
[107.95115649,31.98940288],
[109.37880025,30.55460206],
[107.79515625,29.95213344]]
}
}
-
多边形Polygon
闭合的线要素
{“type”:“Feature”,
“properties”:{},
“geometry”:{
“type”:“Polygon”,
“coordinates”:[
[
[106.10557031,33.33974240],
[106.32563575,32.41708682],
[108.03955725,32.23136636],
[108.25977435,33.15537849],
[106.10503125,33.33902426]] }
}