-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSentinelsat -Download data.py
More file actions
72 lines (54 loc) · 2.26 KB
/
Sentinelsat -Download data.py
File metadata and controls
72 lines (54 loc) · 2.26 KB
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
#This code reads the shapefiles and GeoJSON file and downloads the sentinel image of that area
#Coded_by_Sarthak-Science_hub_Nepal
import time
import datetime
from sentinelsat import SentinelAPI, read_geojson, geojson_to_wkt
import geopandas as gpd
import ogr, os
from osgeo import gdal
from osgeo import ogr
from osgeo import osr
from PyQt5 import QtWidgets,uic
from PyQt5.QtWidgets import QFileDialog
def login():
user_name = call.usernamebox.text()
password = call.Passwordbox.text()
global api
api = SentinelAPI(user_name , password, 'https://scihub.copernicus.eu/dhus')
dataimport()
def dataimport():
#print(Data_path[0])
#Data_path = call.filepathbox.text()
global start_date, end_date
start_date = call.startdatebox.text()
end_date = call.enddatebox.text()
global footprint
if Data_path[0].lower().endswith(('.geojson')):
print("its geojson")
footprint = geojson_to_wkt(read_geojson(Data_path[0]))
#print(footprint)
elif Data_path[0].lower().endswith(('.shp')):
#print("its shape file")
myshpfile = gpd.read_file(Data_path[0])
footprint = myshpfile.to_file("file.geojson", driver='GeoJSON')
elif Data_path[0].lower().endswith(('.wkt')):
footprint = read_wkt(Data_path[0])
datadownload()
def datadownload():
if call.sentinel2box.isChecked() == True:
products = api.query(footprint, date=(start_date, date(2020,4,29)),platformname='Sentinel-2', cloudcoverpercentage = (0, 30))
#print("Downloading Sentinel 2 data.")
if call.sentinel1box.isChecked() == True:
#print("Downloading sentinel 1 data")
products = api.query(footprint, date =(start_date , end_date), platformname ='Sentinel-1', producttype = 'GRD')
api.download_all(products)
def openFileNameDialog():
global Data_path
Data_path = QFileDialog.getOpenFileName(None,'Open File',"","geojson files (*.geojson);;Shape Files (*.shp);; wkt file(*.wkt)")
if __name__ =='__main__':
app = QtWidgets.QApplication([])
call = uic.loadUi('GUI1.ui')
call.pushButton.clicked.connect(login)
call.toolButton.clicked.connect(openFileNameDialog)
call.show()
app.exec()