Package: ndvi2gif
Ndvi2Gif is a python library to create Seasonal Composites based on several statistics applied to some Remote Sensings datastes.
This tool usesGoogle Earth Engine APIand the amazingGeemap package, to create yearly
compositions based on different statistics. We also have addeddeimsPy <https://pypi.org/project/deims/>to get the boundaries of all eLTER sites. So now, you can choose between a shapefile, a map draw or
just use an eLTER DeimsID to get the boundaries for your seasonal composite index.This tool have been updated in the framework ofeLTER H2020andSUMHALprojects, as the main input toPhenoPypython package,
which is the library that we use to get the phenometrics derived from the seasonal vegetation composites.The stats includes at this point are:MaximunMeanMedianPercentile 90Percentile 95The indexes available at present are:NDVIEVIGNDVISAVINDWIAEWIAEWINSHNDSINBRIAnd last, the available datasets are the following:SentinelSentinel 1:https://developers.google.com/earth-engine/datasets/catalog/COPERNICUS_S1_GRDSentinel 2https://developers.google.com/earth-engine/datasets/catalog/COPERNICUS_S2_HARMONIZEDLandsatLandsat 4 TM:https://developers.google.com/earth-engine/datasets/catalog/LANDSAT_LT04_C02_T1_L2Landsat 5 TM:https://developers.google.com/earth-engine/datasets/catalog/LANDSAT_LT05_C02_T1_L2Landsat 7 ETM+:https://developers.google.com/earth-engine/datasets/catalog/LANDSAT_LE07_C02_T1_L2Landsat 8 OLI:https://developers.google.com/earth-engine/datasets/catalog/landsat-8Landsat 9 OLI:https://developers.google.com/earth-engine/datasets/catalog/LANDSAT_LC09_C02_T1_L2MODISMOD09A1:https://developers.google.com/earth-engine/datasets/catalog/MODIS_061_MOD09A1It is possible to create a combination of any of these statistics, indices and datasets. By default, MaximumNDVIis used
as seasonal reducer in order to avoid clouds and cloud shadows. However, we have added others statistic to choice when instantiating the class.
Max remains the default, but sometimes median gives a
better visual result, specially with Landsat 4 and 5 that sometimes have band errors
that can affect NDVI results. Percentile 90 is a good compromise between max and median.Landsat collections and MODIS datasets are Surface Reflectance (SR) data, while
Sentinel 2 is Top of Atmosphere Reflectance (TOA) data. This is
because Surface Reflectance for Sentinel 2, is only available since
2017 but since 2015 for TOA.So, this process generates a raster with 4 (Autumn, Winter, Spring, Summer), 12 (january, febreuary, march, … ) or 24 (p1, p2, …, p24)
bands for every year in the chosen time period.Beyond a nice gif, a lot of information can be obtained with this kind of multi seasonal Vegetation Indexes approach.
Knowing the pair Seasonal Index-Raster band that you chose for your gif, and having colour formation in mind (graphic below),
you could tell which is the phenology, and therfore the crop or every parcel, and even how it changes through the years.
White colours means high NDVI values for the three periods chosen for the vizParams (perennial vegetation), black colour means low NDVI values,
such as permanent water bodies, sand, impervious surfaces, etc…Since we have added SAR data, maybe is no longer correct saying this is an NDVI tool, but with SAR the meaning s very similar to the NDVI approach, in this case we get higher return values when plants are bigger, and very low values for baresoil. So, at the end is another way to have a multi-temporal look at crop growth.Last, you have the choice to download the yearly seasonal index composites as tiff files into your computer,
in case you want the data for further analysis. Also, it have been noticed that Google Earth Engine reducers are
really nice to create gorgeous multi-year composties, even for very large areas with MODIS, e.g. median seasonal NDVI
for whole Africa between 2001 and 2020. So, besides the automatic export for each year, you also have the chance to export
your favourite multi-year compostion in a single file.InstallationThis tiny and humble python package depends on geemap, so geemap will be installed for you. Also it could be a good idea install first geemap in a python environment (you can see the details here:geemap install)and later install ndvi2gif in that environment via pip:pipinstallndvi2gifUsageThis is intend to be executed in a notebook and in tandem with a geemap Map object, so you could navigate around the map
and pick up your region of interest just by drawing a shape, and visualizing different dates and band combinations directly on
the map. However, you could just run it in a command line and pass it a DeimsID, a shapefile or a geojson as roi, and ask for the gif or
for the geotiff rasters.Please, see theexample notebookimportgeemapfromndvi2gifimportNdviSeasonality#You could need a first login to sart with python Earth Engineloginee.Initialize()#Create the Map Object to choose he roisMap=geemap.Map()Map.add_basemap('Google Satellite')Map#Set the roi to last drawn featureroi=Map.draw_last_feature#Instance ndvi2gif#Three different examples here to instantiate the classmyclass=NdviSeasonality(roi)myclass2=NdviSeasonality(roi,2014,2020,'Landsat')myclass3=NdviSeasonality(roi,2010,2015,'MODIS',key='median')#Maybe you feel like playing with the Map and see different colour/season combination efore generate the gifvizParams={'bands':['summer','autumn','winter'],'min':0,'max':0.7,'gamma':[0.95,1.1,1]}Map.addLayer(show,vizParams,'mycropsfirstviz')#Notice that you also can use the Earh Engine amazing analysis capabilitieswintermax=myclass.get_year_composite().select('winter').max()median=myclass.get_year_composite().median()Map.addLayer(wintermax,{'min':0,'max':0.75},'winterMax')Map.addLayer(median,{'min':0.1,'max':0.8},'median')#To get the gif, ust use the method.myclass.get_gif()#Last, you can export your yearly seasonal NDVI composites to your computermyclass.get_export()ContributionsYes, please! Feel free to contribute to this project in any way you like.