Skip to content

Commit

Permalink
Update theropoda.py
Browse files Browse the repository at this point in the history
  • Loading branch information
vieiramesquita authored Jun 30, 2024
1 parent 726bd55 commit 4a6da94
Showing 1 changed file with 37 additions and 4 deletions.
41 changes: 37 additions & 4 deletions theropoda.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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.
Expand All @@ -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:

Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 4a6da94

Please sign in to comment.