-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
726bd55
commit 4a6da94
Showing
1 changed file
with
37 additions
and
4 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 |
---|---|---|
|
@@ -42,6 +42,38 @@ | |
# !pip install pandas | ||
# !pip instal joblib | ||
|
||
# -*- coding: utf-8 -*- | ||
"""TheroPoDa.py | ||
Automatically generated by Colaboratory. | ||
Original file is located at | ||
https://colab.research.google.com/github/vieiramesquita/TheroPoDa/blob/main/TheroPoDa.ipynb | ||
### Name | ||
T(h)eroPoDa - Time Series Extraction for Polygonal Data + Trend Analysis | ||
### Description | ||
Toolkit created to extract Time Series information from Sentinel 2 stored in Earth Engine, perform gap filling and trend analysis image | ||
### Author | ||
Vinícius Vieira Mesquita - [email protected] | ||
### Version | ||
1.1.0 | ||
### Import main libraries | ||
Run the following cell to import the main API's into your session. | ||
""" | ||
|
||
# Commented out IPython magic to ensure Python compatibility. | ||
# %%capture | ||
# if 'google.colab' in str(get_ipython()): | ||
# !pip install earthengine-api | ||
# !pip install pandas | ||
# !pip instal joblib | ||
|
||
import os | ||
import time | ||
import ee | ||
|
@@ -314,6 +346,7 @@ def build_time_series_check(index,obj,id_field,outfile,asset,checker=False): | |
""" | ||
|
||
obj = int(obj) | ||
outfile = outfile+'.db' | ||
|
||
#Checks if the polygon was been processed before | ||
if checker is True: | ||
|
@@ -380,7 +413,7 @@ def build_time_series_check(index,obj,id_field,outfile,asset,checker=False): | |
""" | ||
|
||
#Builds and writes the Polygon ID list | ||
def build_id_list(asset,id_field,colab_folder,db): | ||
def build_id_list(asset,id_field,colab_folder,outname): | ||
""" | ||
Builds and writes a text file containing each Polygon ID used to extract the time series. | ||
|
@@ -403,7 +436,7 @@ def build_id_list(asset,id_field,colab_folder,db): | |
else: | ||
samples_list = samples.toList(samples.size()) | ||
|
||
fileName = os.path.join(colab_folder,db + '_polygonList.txt') | ||
fileName = os.path.join(colab_folder,outname + '_polygonList.txt') | ||
|
||
with open(fileName, "w") as polygon_file: | ||
|
||
|
@@ -435,7 +468,7 @@ def run(asset,id_field,output_name,colab_folder,db): | |
|
||
start_time = time.time() | ||
|
||
fileName_polyList = os.path.join(colab_folder,db + '_polygonList.txt') | ||
fileName_polyList = os.path.join(colab_folder,output_name + '_polygonList.txt') | ||
|
||
#Reading the file which contains the polygons IDs | ||
listPolygons_text = open(fileName_polyList,"r") | ||
|
@@ -482,7 +515,7 @@ def run(asset,id_field,output_name,colab_folder,db): | |
#List of polygons probably with errors | ||
errors_list = [item['errors'] for item in infos if item['errors'] != None] | ||
|
||
fileName_errors = os.path.join(colab_folder,db + '_errors_polygon.txt') | ||
fileName_errors = os.path.join(colab_folder,output_name + '_errors_polygon.txt') | ||
|
||
#Write a file with the erros list | ||
with open(fileName_errors, "w") as errors_file: | ||
|