Alfonso

parent 4fbf44c4
# Copyright (C) 2018 Adan Salazar <asalazargaribay@gmail.com>
#
#
# This file is part of GeoSentinel
#
#
# GeoSentinel is free software you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# GeoSentinel is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with StereoVision. If not, see <http://www.gnu.org/licenses/>.
#
#
#Variables:
#
# * Constructor __init__
# * Into:
# * Access credentials to https://scihub.copernicus.eu/dhus/#/home
# * Username
# * Password
# * Output:
# * api Sentinel
#
# * "getProducts"
# * Into:
# * Area or Polygon
# * Date
# * searchParameters
#
# Other Parameters
# ----------------
# Additional keywords can be used to specify other query parameters,
# e.g. relativeorbitnumber=70.
# See https://scihub.copernicus.eu/twiki/do/view/SciHubUserGuide/3FullTextSearch
# for a full list.
# Range values can be passed as two-element tuples, e.g. cloudcoverpercentage=(0, 30).
# The time interval formats accepted by the ``date`` parameter can also be used with
# any other parameters that expect time intervals (that is: 'beginposition', 'endposition',
#
# * Output:
# * Products_list
#
# * "downloadProducts"
# * Into:
# * products list
# * dir
# * Output:
# * Save images into dir
#
#Functions:
#
# * "getProducts" - Find Sentinel files in URL
# * "downloadProducts" - Download list files Sentinel
# -*- coding: utf-8 -*-
# @package Download Image Sentinel
"""
Install:
$ pip install sentinelsat
Example:
$ python -m doctest -v APISentinel-py
"""
import os
from sentinelsat.sentinel import SentinelAPI
# from geosentinel.ui_utils import check_existing_directory
# from collections import OrderedDict
from datetime import date
class APISentinel(object):
""" Class for Sentinel satellites configuration
......@@ -77,8 +26,15 @@ class APISentinel(object):
"""
def __init__(self,usernam,passw):
"""
Initialize Sentinel Data.
"""The constructor Initialize Sentinel Data.
Args:
param1 (pointer): The object pointer.
param2 (str): Username, access credentials to https://scihub.copernicus.eu/dhus/#/home.
param3 (str): Password, access credentials to https://scihub.copernicus.eu/dhus/#/home.
Returns:
pointer: The object pointer.
"""
self.username = usernam
self.password = passw
......@@ -90,10 +46,35 @@ class APISentinel(object):
self.api = SentinelAPI(self.username, self.password, self.URL_Sentinel)
def getProducts(self, area, date, searchParameters):
"""Gets products list Sentinel
Args:
param1 (pointer): The object pointer.
param2 (str): Area to find images.
param3 (str): Init date and end date.
param4 (str): Type platform Sentinel-1 or Sentinel-2
Other Parameters: Additional keywords can be used to specify other query parameters, e.g. relativeorbitnum-
ber=70. See https://scihub.copernicus.eu/twiki/do/view/SciHubUserGuide/3FullTextSearch for a full list. Ran-
ge values can be passed as two-element tuples, e.g. cloudcoverpercentage=(0, 30). The time interval formats
accepted by the ``date`` parameter can also be used with any other parameters that expect time intervals
(that is:'beginposition', 'endposition',
Returns:
str: Product list Sentinel found.
"""
products_list = self.api.query(area, date, **searchParameters)
return products_list
def downloadProducts(self,products,dir):
"""Download product(s) list Sentinel
Args:
param1 (pointer): The object pointer.
param2 (str): Product(s) list Sentinel found.
param3 (str): Local path to save download files.
Returns:
Save Sentinel files.
"""
os.chdir(dir)
self.api.download_all(products)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment