Commit b157a93b authored by Laura LINDEPERG's avatar Laura LINDEPERG
Browse files

Add data to clip

parent fb9853cd
......@@ -14,7 +14,7 @@ import rioxarray as rxr
# **************************** Data *****************************
# Watersheds
## Watersheds
## ----- When creating complete waterheds file ----------
# shp_stations_filepath = 'E:/DonneesLaura/BanqueHydro/Shapes/StationBHYDRO_L93.shp'
......@@ -29,36 +29,44 @@ shp_BV_IV = gpd.read_file(shp_BV_IV_path)
# shp_BV_VV = gpd.read_file('C:/Users/laura.lindeperg/Documents/DonneesLaura/Watersheds/BV_InvalidesValides/BVsValidesValides.shp')
# -----------------------
shp_watersheds_path = 'C:/Users/laura.lindeperg/Documents/DonneesLaura/Watersheds/complete_df_wrong_geometries.shp'
shp_watersheds_path = 'C:/Users/laura.lindeperg/Documents/DonneesLaura/Watersheds/616_Catchments.shp'
shp_foldername = 'C:/Users/laura.lindeperg/Documents/DonneesLaura/Watersheds/GEOMETRY/'
shp_watersheds = gpd.read_file(shp_watersheds_path)
## TOPO
# BDAlti 25m
BDAlti_map_path = 'C:/Users/laura.lindeperg/Documents/DonneesLaura/BDAlti_25m/France_BDAlti_25m.tif'
BDAlti_map = rxr.open_rasterio(BDAlti_map_path).squeeze()
## GEOMORPHO
# Depth to Bedrock
depth_to_bedrock_path = 'C:/Users/laura.lindeperg/Documents/DonneesLaura/SoilGrids/BDTICM_M_250m_France.tif'
depth_to_bedrock = rxr.open_rasterio(depth_to_bedrock_path).squeeze()
# BDTopage
hydro_sections_path = 'C:/Users/laura.lindeperg/Documents/DonneesLaura/Topage/TronconHydrographique_FXX-shp/TronconHydrographique_FXX.shp'
hydro_sections = gpd.read_file(hydro_sections_path)
# BDCarthage
hydro_sections_Carthage_path = 'C:/Users/laura.lindeperg/Documents/DonneesLaura/Topage/troncon-hydrographique/TRONCON_HYDROGRAPHIQUE.shp'
# BDCarthage - v.2017
hydro_sections_Carthage_path = 'C:/Users/laura.lindeperg/Documents/DonneesLaura/BDCarthage/TronconHydrograElt_FXX-shp/TronconHydrograElt_FXX.shp'
hydro_sections_Carthage = gpd.read_file(hydro_sections_Carthage_path)
# ZHp (raster)
ZHp_map_path = 'C:/Users/laura.lindeperg/Documents/DonneesLaura/ZonesHumidesPotentielles/mph-fr.tif'
ZHp_map = rxr.open_rasterio(ZHp_map_path).squeeze()
# BDAlti 25m
BDAlti_map_path = 'C:/Users/laura.lindeperg/Documents/DonneesLaura/BDAlti_25m/France_BDAlti_25m.tif'
BDAlti_map = rxr.open_rasterio(BDAlti_map_path).squeeze()
## GEOL
# GLHYMPS
GLHYMPS_shp_path = 'C:/Users/laura.lindeperg/Documents/DonneesLaura/GLHYMPS/GLHYMPS_FRcropped.shp'
GLHYMPS_shp = gpd.read_file(GLHYMPS_shp_path)
# BDLisa
BDLisa_shp_path = 'C:/Users/laura.lindeperg/Documents/DonneesLaura/BD_Lisa/RegionalHydrogeologyAnalysisMe/BD_Lisa_regionalhydrogeology.shp'
BDLisa_shp = gpd.read_file(BDLisa_shp_path)
......@@ -80,6 +88,7 @@ FC_map_path = 'C:/Users/laura.lindeperg/Documents/DonneesLaura/FS_water_2016_07/
FC_map = rxr.open_rasterio(FC_map_path).squeeze()
## HYDROCLIMATIC
# Banque Hydro
banquehydro_foldername = 'C:/Users/laura.lindeperg/Documents/DonneesLaura/BanqueHydro/Export2020/'
......@@ -174,11 +183,51 @@ watershed_code = shp_watersheds.loc[:,'Code']
# watershed_code_IV = shp_BV_IV.loc[shp_BV_IV.loc[:,'Code'].isin(watershed_code)].loc[:, 'Code']
# Get a sample of them for test
code_for_test = watershed_code.loc[0:1]
code_for_test = watershed_code.loc[614:]
# code_for_test = ['K9341810']
# code_for_test = ['J4742020']
## TOPOGRAPHY
# GLHYMPS
for i in code_for_test:
# for i in watershed_code:
## Get shp
shp_contour_i = gpd.read_file(shp_foldername+i+'.shp')
# Hydro sections - BDCarthage v.2017
try:
shpfile_GLHYMPS = gpd.clip(GLHYMPS_shp, shp_contour_i)
except:
shpfile_GLHYMPS = gpd.overlay(GLHYMPS_shp, shp_contour_i)
shpfile_GLHYMPS.to_file('C:/Users/laura.lindeperg/Documents/DonneesLaura/Watersheds/GEOL/GLHYMPS/'+i+'_GLHYMPS.shp')
## GEOMORPHOLOGY
# BD Carthage v.2017 and Depth to Bedrock
for i in code_for_test:
# for i in watershed_code:
## Get shp
shp_contour_i = gpd.read_file(shp_foldername+i+'.shp')
# Hydro sections - BDCarthage v.2017
try:
shpfile_BDCarthage = gpd.clip(hydro_sections_Carthage, shp_contour_i)
except:
shpfile_BDCarthage = gpd.overlay(hydro_sections_Carthage, shp_contour_i)
shpfile_BDCarthage.to_file('C:/Users/laura.lindeperg/Documents/DonneesLaura/Watersheds/GEOMORPHO/BDCarthage/'+i+'_BDCarthage.shp')
## Depth to Bedrock
raster_DTB = depth_to_bedrock.rio.clip(shp_contour_i.geometry.apply(mapping), shp_contour_i.crs)
raster_DTB.rio.to_raster('C:/Users/laura.lindeperg/Documents/DonneesLaura/Watersheds/GEOMORPHO/DTB/'+i+'_DTB_250m.tif')
# BDAlti 25m
......@@ -215,8 +264,7 @@ for i in watershed_code:
raster_FC.rio.to_raster('C:/Users/laura.lindeperg/Documents/DonneesLaura/Watersheds/GEOL/JRC-ESDAC/FC/'+i+'_FC.tif')
## GEOMORPHO
# BD Topage
# for i in code_for_test:
for i in watershed_code:
......@@ -259,7 +307,7 @@ for i in watershed_code:
## SHP and GEOL
## GEOL
# for i in code_for_test:
for i in watershed_code:
......
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