Alfonso

parent 595b6e78
# 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
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
Test Case
>>> sentinel = APISentinel('asalazarg', 'geo135asg')
>>> dir="../../../Documentos/Image_Sentinel"
>>> products = sentinel.getProducts("POLYGON((-89.99450683593753 21.279137394108716,-89.13757324218751 21.2996106049456,-89.30236816406251 20.68418377935238,-90.0494384765625 20.715015145512098,-89.99450683593753 21.279137394108716))", ('20151219', date(2015,12,29)), {"platformname":"Sentinel-1"})
>>> print len(products)
3
>>> sentinel.downloadProducts(products,dir)
"""
def __init__(self,usernam,passw):
"""
Initialize Sentinel Data.
"""
self.username = usernam
self.password = passw
self.URL_Sentinel = 'https://scihub.copernicus.eu/dhus'
# self.plot_width = 7
# self.plot_height = 7
# self.intersection_th = 30
self.api = SentinelAPI(self.username, self.password, self.URL_Sentinel)
def getProducts(self, area, date, searchParameters):
products_list = self.api.query(area, date, **searchParameters)
return products_list
def downloadProducts(self,products,dir):
os.chdir(dir)
self.api.download_all(products)
......@@ -41,6 +41,12 @@ SENTINEL_ARGUMENTS.add_argument("overlap", type=int, help="Percentage of overlap
SENTINEL_ARGUMENTS.add_argument("output_folder", help="Folder to download Sentinel files ")
SENTINEL_ARGUMENTS.add_argument("username", help="User name platform to download Sentinel files")
SENTINEL_ARGUMENTS.add_argument("password", help="Password platform to download Sentinel files")
SENTINEL_ARGUMENTS.add_argument("input_file", help="file geojson local path")
SENTINEL_FIND_ARGUMENTS = ArgumentParser(add_help=False)
......
......@@ -44,11 +44,11 @@ import zipfile
from collections import OrderedDict
from osgeo import ogr
#from osgeo import ogr
from osgeo import gdal
#from osgeo import gdal
from osgeo.gdalconst import *
#from osgeo.gdalconst import *
from sentinelsat.sentinel import SentinelAPI #read_geojson, geojson_to_wkt
......
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