An error occurred while loading the file. Please try again.
-
Laura LINDEPERG authoredecb2dfce
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import geopandas as gpd
class GeologicProperties(object):
def __init__(self, maingeol_id=-1, maingeol_description=-1, age=-1, proportion=-1, maingeol_age=-1, maingeol_age_proportion=-1):
self.maingeol_id = maingeol_id
self.maingeol_description = maingeol_description
self.maingeol_proportion = proportion
self.age = age # [min, mean, max] age averaged from the 1/1000000e brgm map
self.maingeol_age = maingeol_age
self.maingeol_age_proportion = maingeol_age_proportion
def extract_main_geology_from_filename(self, geol_foldername, catchment_contour_shp):
geol_shp = gpd.read_file(geol_foldername)
self.extract_main_geology(geol_shp, catchment_contour_shp)
def extract_main_geology(self, geol_shp, catchment_contour_shp):
geol_shp = gpd.clip(geol_shp, catchment_contour_shp)
geol_shp['area'] = geol_shp.geometry.area / 1e6
geol_shp['prop'] = geol_shp.area / sum(geol_shp.area)
geol_shp = geol_shp.loc[geol_shp.prop == max(geol_shp.prop)]
self.maingeol_proportion = geol_shp.prop.values[0]
self.maingeol_description = geol_shp.Type.values[0]
self.maingeol_id = geol_shp.index.values[0]
def extract_average_age_geology(self, geol_foldername, catchment_contour_shp):
geol_shp = gpd.read_file(geol_foldername)
try:
gpd.clip(geol_shp, catchment_contour_shp)
except:
gpd.overlay(geol_shp, catchment_contour_shp)
geol_shp['area'] = geol_shp.geometry.area / 1e6
geol_shp['prop'] = geol_shp.area / sum(geol_shp.area)
age_min = sum(geol_shp.prop*geol_shp.AGE_SUP)
age_max = sum(geol_shp.prop*geol_shp.AGE_INF)
age_mean = sum([age_max, age_min])/2
self.age = [age_min, age_mean, age_max]
self.maingeol_age_proportion = max(geol_shp.prop)
geol_shp = geol_shp.loc[geol_shp.prop == max(geol_shp.prop)]
maingeol_age_min = geol_shp.AGE_SUP.values[0]
maingeol_age_max = geol_shp.AGE_INF.values[0]
maingeol_age_mean = sum([maingeol_age_min, maingeol_age_max])/2
self.maingeol_age = [maingeol_age_min, maingeol_age_mean, maingeol_age_max]