Commit 7289385d authored by Laura LINDEPERG's avatar Laura LINDEPERG
Browse files

Add elevation and slope indicators

parent ffbc33c5
......@@ -11,12 +11,14 @@ import pandas as pd
class GeomorphologicProperties(object):
def __init__(self, code=-1, ZHp_ratio=-1, order_1_ratio=-1, intermittent_ratio=-1, drainage_density=-1):
def __init__(self, code=-1, ZHp_ratio=-1, order_1_ratio=-1, intermittent_ratio=-1, drainage_density=-1, mean_elevation = -1, median_slope=-1):
self.code = code
self.ZHp_ratio = ZHp_ratio
self.order_1_ratio = order_1_ratio
self.intermittent_ratio = intermittent_ratio
self.drainage_density = drainage_density
self.mean_elevation = mean_elevation
self.median_slope = median_slope
......@@ -73,6 +75,19 @@ class GeomorphologicProperties(object):
self.drainage_density = drainage_density
def extract_mean_elevation(self, topographic_property_map):
import numpy.ma as ma
mean_elevation = np.mean(ma.masked_values(topographic_property_map, -99999.))
self.mean_elevation = mean_elevation
def extract_median_slope(self, topographic_property_map):
import numpy.ma as ma
slope = ma.masked_values(topographic_property_map, -99999.)
slope = slope.filled(np.nan)
median_slope = np.nanmedian(slope)
self.median_slope = median_slope
def extract_geomorphologic_properties(self, contour, ZHp, hydro_sections_Topage, hydro_sections_Carthage):
self.compute_ZHp_ratio(ZHp)
......
......@@ -30,7 +30,11 @@ topage_foldername = 'C:/Users/laura.lindeperg/Documents/DonneesLaura/Watersheds/
## BDCarthage
carthage_foldername = 'C:/Users/laura.lindeperg/Documents/DonneesLaura/Watersheds/GEOMORPHO/BDCarthage/'
## BDAlti 25m
bdalti_foldername = 'C:/Users/laura.lindeperg/Documents/DonneesLaura/Watersheds/GEOMORPHO/BDAlti_25m/'
## Slope
slope_foldername = 'C:/Users/laura.lindeperg/Documents/DonneesLaura/Watersheds/GEOMORPHO/Slope/'
# List of the stations'codes
......@@ -45,16 +49,21 @@ code_for_test = watershed_code.loc[0:3]
from GeomorphologicProperties import GeomorphologicProperties
geomorpho_indicators = pd.DataFrame()
# for i in code_for_test:
for i in watershed_code:
for i in code_for_test:
# for i in watershed_code:
watershed_contour_i = gpd.read_file(shp_foldername+i+'.shp')
ZHp_i = rxr.open_rasterio(ZHp_foldername+i+'_ZHp.tif')
hydro_sections_Topage_i = gpd.read_file(topage_foldername+i+'_BDTopage.shp')
hydro_sections_Carthage_i = gpd.read_file(carthage_foldername+i+'_BDCarthage.shp')
bdalti_i = rxr.open_rasterio(bdalti_foldername+i+'_BDAlti_25m.tif')
slope_i = rxr.open_rasterio(slope_foldername+i+'_slope_25m.tif')
geomorpho_i = GeomorphologicProperties(i)
# geomorpho_i.compute_ZHp_ratio(ZHp_i)
geomorpho_i.extract_geomorphologic_properties(watershed_contour_i, ZHp_i, hydro_sections_Topage_i, hydro_sections_Carthage_i)
geomorpho_i.extract_mean_elevation(bdalti_i)
geomorpho_i.extract_median_slope(slope_i)
geomorpho_indicators = geomorpho_indicators.append(geomorpho_i.__dict__, ignore_index=True)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment