-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added: Sentinelsat - download and extract
- Loading branch information
1 parent
e795bf1
commit 8edc025
Showing
4 changed files
with
36 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
*.pyc | ||
input_details.py | ||
input_details.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Ignore everything in this directory | ||
* | ||
# Except this file | ||
!.gitignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from sentinelsat import SentinelAPI | ||
import zipfile | ||
import os | ||
|
||
def download_data (username, password, latitude, longitude): | ||
api = SentinelAPI(username, | ||
password, 'https://scihub.copernicus.eu/dhus') | ||
footprint = f'POINT ({latitude} {longitude})' | ||
data_populate = api.query(footprint, date=('NOW-12MONTHS','NOW'), | ||
order_by='cloudcoverpercentage', | ||
platformname='Sentinel-2', | ||
processinglevel='Level-2A', | ||
cloudcoverpercentage=(0,10)) | ||
data_database = api.to_geodataframe(data_populate) | ||
data_database_sorted = data_database.sort_values('cloudcoverpercentage', | ||
ascending=True).reset_index() | ||
print(data_database_sorted['index'].iloc[0]) | ||
print("\ndownloading data... please wait...\n") | ||
data_download = api.download(data_database_sorted['index'].iloc[0], | ||
directory_path='./data') | ||
print("\ndownload complete!\n") | ||
zip = zipfile.ZipFile(os.path.join('.', 'data', | ||
data_download['title'] + '.zip')) | ||
zip.extractall('./data') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,10 @@ | ||
from sentinelsat import SentinelAPI | ||
import geopandas as gpd | ||
import pandas as pd | ||
from shapely.geometry import MultiPolygon, Polygon | ||
import numpy as np | ||
import os | ||
|
||
import input_details | ||
from download_data import download_data | ||
|
||
api = SentinelAPI(input_details.username, input_details.password, 'https://scihub.copernicus.eu/dhus') | ||
|
||
footprint = f'POINT ({input_details.latitude} {input_details.longitude})' | ||
print(footprint) | ||
|
||
data_populate = api.query(footprint, date=('NOW-12MONTHS','NOW'), order_by='cloudcoverpercentage', platformname='Sentinel-2', processinglevel='Level-2A', cloudcoverpercentage=(0,10)) | ||
print(len(data_populate)) | ||
def main(): | ||
username, password = input_details.username, input_details.password | ||
latitude, longitude = input_details.latitude, input_details.longitude | ||
download_data(username, password, latitude, longitude) | ||
|
||
data_database = api.to_geodataframe(data_populate) | ||
print(data_database) | ||
if __name__ == '__main__': | ||
main() |