GithubHelp home page GithubHelp logo

pedroananias / abyo Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 136 KB

Algorithm that allows the extraction of annual algal bloom occurrence in a study area

License: MIT License

Shell 1.51% Python 98.49%

abyo's Introduction

Algal Bloom Yearly Occurrence

Module responsable for extracting Algal Bloom Yearly Occurences in a region of interest based on images from Google Earth Engine API

Dependencies

  • Python 3.7.7 64-bit ou superior
  • Modules: oauth2client earthengine-api matplotlib pandas numpy requests pillow natsort geojson argparse logging hashlib joblib gctraceback warnings

Attention, before running:

Before running the script and after installing the libraries, you must authenticate with the Google Earth Engine API using the following command:

earthengine authenticate

How to execute the default script?

python /path/to/abyo/script.py --lat_lon=-48.84725671390528,-22.04547298853004,-47.71712046185493,-23.21347463046867 --name=bbhr --date_start=1985-01-01 --date_end=2018-12-31

What are the results?

The script will generate annual results of occurrence of algae and clouds blooming in the inserted study area. Therefore, a folder located in 'data' is created and named based on the date and version of the script executed. Example: /path/to/abyo/data/20200701_111426[v=V1-bbhr,date_start=1985-01-01,date_end=2001-12-31].

ATTENTION: big date range tends to lead to memory leak, stopping the script execution. It is always a good pratice to split the dates in two or three parts, unless you have a big amount of memory in your computer.

The following results are generated:

  • timeseries.csv (Annual time series of pixels, year, latitude, longitude and occurrences of algae bloom (based on the threshold of the Slope index) and clouds)
  • occurrences.png (Graphs of occurrences separated annually from algal blooms)
  • occurrences_clouds.png (Graphs of occurrences separated annually from clouds)
  • occurrences.json (GeoJSON of occurrences by year with parameters (occurrence, not_occurrence, pct_occurrence, cloud, pct_cloud, year and instants) that can be imported into QGIS and filtered)
  • tiff/{date}.zip (ZIP of GeoTIFFs comprehending bands Cloud/Only Water Body, Occurrence/Only Water Body and Not Occurrence/Only Water Body of the study area. If the script can not save those images in locally, will send them to Google Drive)

Exporting GeoTIFFs to Google Drive

When using the 'save_collection_tiff' function, if the script can not save images locally, will send them to Google Drive to a folder called 'abyo_name_version.tiff' for user who is authenticated. Daily images used in the composition of the annual time series are saved. These images will be separated by the following bands: Red, Green, Blue, Cloud/Only Water Body, Occurrence/Only Water Body and Not Occurrence/Only Water Body. However, after running the Abyo script, images are likely to take a while to be inserted into Drive due to processing time. It is necessary to wait approximately 1 day until they are all available, depending on the size of the study area.

Example

# Import
import ee
from modules import abyo

# Initialize Google Earth Engine
ee.Initialize()

# folder where to save results
folder = "/path/to/desired/folder"

# create algorithm object
abyo = abyo.Abyo(lat_lon="-48.84725671390528,-22.04547298853004,-47.71712046185493,-23.21347463046867",
                date_start=dt.strptime("1985-01-01", "%Y-%m-%d"),
                date_end=dt.strptime("2018-12-31", "%Y-%m-%d"),
                date_start2=None,
                date_end2=None,
                sensor="landsat578",
                cache_path=folder, 
                force_cache=False,
                indice="mndwi,ndvi,fai,sabi,slope",
                min_occurrence=4,
                shapefile="users/pedroananias/bruno/bbhr")

# creating yearly timeseries
abyo.process_timeseries_data()

# save timeseries in csv file
abyo.save_dataset(df=abyo.df_timeseries, path=folder+'/timeseries.csv')

# save ocurrences plot (yearly and clouds)
abyo.save_occurrences_plot(df=abyo.df_timeseries, folder=folder)

# save geojson occurrences
abyo.save_occurrences_geojson(df=abyo.df_timeseries, folder+"/geojson")

# save daily images to Google Drive
abyo.save_collection_tiff(folder=folder+"/tiff", folderName="bbhr")

abyo's People

Watchers

Pedro Henrique Moraes Ananias avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.