Skip to content
Snippets Groups Projects
Commit d0f76e7e authored by pascal.mouquet_ird.fr's avatar pascal.mouquet_ird.fr
Browse files

added ireci ans ndre in get_processed_indices_vect

parent 9749ac2b
No related branches found
No related tags found
No related merge requests found
Pipeline #31 failed
......@@ -160,25 +160,25 @@ def get_processed_indices_vect(
#~ indices_index = set().union(ndvi_index, ndwigao_index, ndwimcf_index, mndwi_index)
lib = Library()
indices_index = {t for c in (getattr(lib, toto) for toto in ['l2a', 'ndvi', 'ndwigao', 'ndwimcf', 'mndwi']) for t in c}
total_index = {t for c in (getattr(lib, toto) for toto in ['l1c', 'l2a', 'ndvi', 'ndwigao', 'ndwimcf', 'mndwi']) for t in c}
indices_index = {t for c in (getattr(lib, toto) for toto in ['l2a', 'ndvi', 'ndwigao', 'ndwimcf', 'mndwi', 'ndre', 'ireci']) for t in c}
total_index = {t for c in (getattr(lib, toto) for toto in ['l1c', 'l2a', 'ndvi', 'ndwigao', 'ndwimcf', 'mndwi', 'ndre', 'ireci']) for t in c}
complement_index = total_index - indices_index
tile_count = {}
for key in total_index:
#~ logger.info(key)
tile_count[key]={"lc1": 0, "l2a": 0, 'ndvi': 0, 'ndwigao': 0, 'ndwimcf': 0, 'mndwi': 0}
tile_count[key]={"lc1": 0, "l2a": 0, 'ndvi': 0, 'ndwigao': 0, 'ndwimcf': 0, 'mndwi': 0, 'ndre': 0, 'ireci': 0}
tile = Tile(key)
for p in ['l1c', 'l2a']:
tile_count[key][p] = len(getattr(tile, p))
for p in ['ndvi', 'ndwigao', 'ndwimcf', 'mndwi']:
for p in ['ndvi', 'ndwigao', 'ndwimcf', 'mndwi', 'ndre', 'ireci']:
try:
tile_count[key][p] = len(getattr(tile, p).masks)
tile_count[key][p] = len(getattr(tile, p).masks.cm001)
except:
pass
# pour supprimer les tuiles ayant tous les indices à 0
indices_index_nonull = {k: v for k, v in tile_count.items() if sum(v[indice] for indice in [z for z in v.keys() if z in ['ndvi', 'ndwigao', 'ndwimcf', 'mndwi']])}
indices_index_nonull = {k: v for k, v in tile_count.items() if sum(v[indice] for indice in [z for z in v.keys() if z in ['ndvi', 'ndwigao', 'ndwimcf', 'mndwi', 'ndre', 'ireci']])}
# Couche des indices
query_str = 'or '.join(['"{}" = "{}"'.format("Name", idx) for idx in indices_index_nonull.keys()])
......@@ -191,7 +191,10 @@ def get_processed_indices_vect(
"NDVI", "NDVI_F", "NDVI_L", \
"NDWIGAO", "NDWIGAO_F", "NDWIGAO_L", \
"NDWIMCF", "NDWIMCF_F", "NDWIMCF_L", \
"MNDWI", "MNDWI_F", "MNDWI_L"]:
"MNDWI", "MNDWI_F", "MNDWI_L",
"NDRE", "NDRE_F", "NDRE_L",
"IRECI", "IRECI_F", "IRECI_L",
]:
field_name = ogr.FieldDefn(name, ogr.OFTString)
field_name.SetWidth(10)
out_layer.CreateField(field_name)
......@@ -219,35 +222,52 @@ def get_processed_indices_vect(
feat.SetField("NDVI", tile_count[tile_name]['ndvi'])
try:
feat.SetField("NDVI_F", tile.ndvi.masks.first.date.strftime("%d/%m/%Y"))
feat.SetField("NDVI_L", tile.ndvi.masks.last.date.strftime("%d/%m/%Y"))
feat.SetField("NDVI_F", tile.ndvi.masks.cm001.first.date.strftime("%d/%m/%Y"))
feat.SetField("NDVI_L", tile.ndvi.masks.cm001.last.date.strftime("%d/%m/%Y"))
except:
feat.SetField("NDVI_F", 0)
feat.SetField("NDVI_L", 0)
feat.SetField("NDWIGAO", tile_count[tile_name]['ndwigao'])
try:
feat.SetField("NDWIGAO_F", tile.ndwigao.masks.first.date.strftime("%d/%m/%Y"))
feat.SetField("NDWIGAO_L", tile.ndwigao.masks.last.date.strftime("%d/%m/%Y"))
feat.SetField("NDWIGAO_F", tile.ndwigao.masks.cm001.first.date.strftime("%d/%m/%Y"))
feat.SetField("NDWIGAO_L", tile.ndwigao.masks.cm001.last.date.strftime("%d/%m/%Y"))
except:
feat.SetField("NDWIGAO_F", 0)
feat.SetField("NDWIGAO_L", 0)
feat.SetField("NDWIMCF", tile_count[tile_name]['ndwimcf'])
try:
feat.SetField("NDWIMCF_F", tile.ndwimcf.masks.first.date.strftime("%d/%m/%Y"))
feat.SetField("NDWIMCF_L", tile.ndwimcf.masks.last.date.strftime("%d/%m/%Y"))
feat.SetField("NDWIMCF_F", tile.ndwimcf.masks.cm001.first.date.strftime("%d/%m/%Y"))
feat.SetField("NDWIMCF_L", tile.ndwimcf.masks.cm001.last.date.strftime("%d/%m/%Y"))
except:
feat.SetField("NDWIMCF_F", 0)
feat.SetField("NDWIMCF_L", 0)
feat.SetField("MNDWI", tile_count[tile_name]['mndwi'])
try:
feat.SetField("MNDWI_F", tile.mndwi.masks.first.date.strftime("%d/%m/%Y"))
feat.SetField("MNDWI_L", tile.mndwi.masks.last.date.strftime("%d/%m/%Y"))
feat.SetField("MNDWI_F", tile.mndwi.masks.cm001.first.date.strftime("%d/%m/%Y"))
feat.SetField("MNDWI_L", tile.mndwi.masks.cm001.last.date.strftime("%d/%m/%Y"))
except:
feat.SetField("MNDWI_F", 0)
feat.SetField("MNDWI_L", 0)
feat.SetField("NDRE", tile_count[tile_name]['ndre'])
try:
feat.SetField("NDRE_F", tile.ndre.masks.cm001.first.date.strftime("%d/%m/%Y"))
feat.SetField("NDRE_L", tile.ndre.masks.cm001.last.date.strftime("%d/%m/%Y"))
except:
feat.SetField("NDRE_F", 0)
feat.SetField("NDRE_L", 0)
feat.SetField("IRECI", tile_count[tile_name]['ireci'])
try:
feat.SetField("IRECI_F", tile.ireci.masks.cm001.first.date.strftime("%d/%m/%Y"))
feat.SetField("IRECI_L", tile.ireci.masks.cm001.last.date.strftime("%d/%m/%Y"))
except:
feat.SetField("IRECI_F", 0)
feat.SetField("IRECI_L", 0)
out_layer.SetFeature(feat)
fill_fields(out_layer)
......@@ -265,7 +285,10 @@ def get_processed_indices_vect(
"NDVI", "NDVI_F", "NDVI_L", \
"NDWIGAO", "NDWIGAO_F", "NDWIGAO_L", \
"NDWIMCF", "NDWIMCF_F", "NDWIMCF_L", \
"MNDWI", "MNDWI_F", "MNDWI_L"]:
"MNDWI", "MNDWI_F", "MNDWI_L",
"NDRE", "NDRE_F", "NDRE_L",
"IRECI", "IRECI_F", "IRECI_L",
]:
field_name = ogr.FieldDefn(name, ogr.OFTString)
field_name.SetWidth(10)
out_layer.CreateField(field_name)
......@@ -284,7 +307,9 @@ def get_processed_indices_vect(
"NDVI", "NDVI_F", "NDVI_L", \
"NDWIGAO", "NDWIGAO_F", "NDWIGAO_L", \
"NDWIMCF", "NDWIMCF_F", "NDWIMCF_L", \
"MNDWI", "MNDWI_F", "MNDWI_L"]:
"MNDWI", "MNDWI_F", "MNDWI_L",
"NDRE", "NDRE_F", "NDRE_L",
"IRECI", "IRECI_F", "IRECI_L"]:
field_name = ogr.FieldDefn(name, ogr.OFTString)
field_name.SetWidth(10)
out_layer.CreateField(field_name)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment