1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
| @author: maji
"""
# connect to the API
import sentinelsat
from sentinelsat import SentinelAPI, read_geojson, geojson_to_wkt
from datetime import date
from collections import OrderedDict
import panda as pd
api = SentinelAPI("username", "mot de passe",https://scihub.copernicus.eu/dhus/#/home '')
### download single scene by known product id
### api.download(<product_id>)
# search by polygon, time, and SciHub query keywords, polygone geojson en WGS84 obligatoire
# possibilité de faire une recherche directement avec les corrdonnée d'un polygone ou d'un point
footprint = geojson_to_wkt(read_geojson('test.geojson'))
products = api.query(footprint,
date=("20160713", "20160722"),
platformname="sentinel-2",
cloudcoverpercentage=(0, 10))
# d'autres filtre sont disponibles et adaptés à chaque plateforme:
# date = ("NOW-2DAYS","NOW")
# producttype = "GRD",
# orbitdirection = "ascending",
# polarisationmode = "VV + VH",
# sensoroperationamode = "IW",
print(products)
# convert to Pandas DataFrame
products_df = api.to_dataframe(products)
# sort and limit to first 5 sorted products
products_df_sorted = products_df.sort_values(['cloudcoverpercentage', 'ingestiondate'], ascending=[True, True])
print(product_df_sorted)
products_df_sorted = products_df_sorted.head(5)
# download all results from the search
api.download_all(products)
# download sorted and reduced products
api.download_all(products_df_sorted['id'])
# 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)
[23:15, 13/10/2018] Zik: # 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('map.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)
# 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) |
Partager