diff --git a/Rcode/advanced_settings.R b/Rcode/advanced_settings.R index d052db4dc178a4f12bb941b54e7eb0424e2b3019..c308ca4c39374ab2127b222e6d0a437892c3ad86 100644 --- a/Rcode/advanced_settings.R +++ b/Rcode/advanced_settings.R @@ -46,6 +46,7 @@ print(paste('resources_path :', resources_path)) # Logo filename logo_dir = 'logo' +PRlogo_file = 'logo_Prefet_bassin.png' AEAGlogo_file = 'agence-de-leau-adour-garonne_logo.png' INRAElogo_file = 'Logo-INRAE_Transparent.png' FRlogo_file = 'Republique_Francaise_RVB.png' @@ -65,7 +66,8 @@ sbs_shpname = 'SousBassinHydrographique.shp' # Path to the shapefile for station basins shape from 'computer_data_path' cbs_shpdir = file.path(shp_dir, 'bassin_station') -cbs_shpname = 'BV_4207_stations.shp' +cbs_shpname = c('BV_4207_stations.shp', '3BVs_FRANCE_L2E_2018.shp') +cbs_coord = c("L93", "L2") # Path to the shapefile for river shape from 'computer_data_path' rv_shpdir = file.path('map', 'river') @@ -112,11 +114,11 @@ TXTlistname = ## 3. ANALYSIS PARAMETERS ____________________________________________ ### 3.1. Station analysis ____________________________________________ to_analyse = c( - 'QA' - # 'QMNA', - # 'VCN10', - # 'tDEB', - # 'tCEN' + 'QA', + 'QMNA', + 'VCN10', + 'tDEB', + 'tCEN' ) ### 3.2. Climate analysis ____________________________________________ @@ -172,7 +174,7 @@ fast_format = FALSE alpha = 0.1 allMonth = FALSE - + ## 4. PLOTTING OPTIONS _______________________________________________ # If the hydrological network needs to be plot @@ -190,14 +192,14 @@ axis_xlim = # 'map' : map about trend analyses to_plot_station = c( - # 'datasheet' - # 'table' - 'map' + 'datasheet' + # 'table', + # 'map' ) map_to_plot = c( - 'regime' - # 'trend' - # 'mean' + 'regime', + 'trend', + 'mean' ) diff --git a/Rcode/plotting/layout.R b/Rcode/plotting/layout.R index b4720d3f35e90157ea4cb2664cb1c1623508bae9..61056912ddda9cfeb8c4b84e4ae2b3641d803ec0 100644 --- a/Rcode/plotting/layout.R +++ b/Rcode/plotting/layout.R @@ -49,8 +49,7 @@ library(shadowtext) library(png) library(ggrepel) - - +, # Sourcing R file source(file.path('Rcode', 'plotting', 'datasheet.R'), encoding='UTF-8') source(file.path('Rcode', 'plotting', 'map.R'), encoding='UTF-8') diff --git a/Rcode/plotting/map.R b/Rcode/plotting/map.R index 9f7240a2630ee303b49197f9d108b5bde9224459..6fbdc269927af7bbd713156381fa4e940e456958 100644 --- a/Rcode/plotting/map.R +++ b/Rcode/plotting/map.R @@ -93,9 +93,9 @@ map_panel = function (list_df2plot, df_meta, df_shapefile, idPer_trend=1, } if (mapType == 'regime') { - regimeColorSample = c('#293648', - '#7b9093', - '#a5c5d9') + regimeColorSample = c('#005249', + '#3e8baa', + '#a9c0cb') names(regimeColorSample) = c('Pluvial', 'Transition', 'Nival Glaciaire') @@ -209,7 +209,8 @@ map_panel = function (list_df2plot, df_meta, df_shapefile, idPer_trend=1, color="grey40", fill=NA, size=sizefr) if (mapType == 'regime') { - color = regimeColor[match(df_codeBasin$code, Code)] + # color = regimeColor[match(df_codeBasin$code, Code)] + color = 'grey20' map = map + # Plot the hydrological code basins geom_polygon(data=df_codeBasin, @@ -451,10 +452,10 @@ map_panel = function (list_df2plot, df_meta, df_shapefile, idPer_trend=1, # Extracts the localisation of the current station lontmp = - df_meta[df_meta$code == code,]$L93X_m_BH + df_meta$L93X_m_BH[df_meta$code == code] lattmp = - df_meta[df_meta$code == code,]$L93Y_m_BH - + df_meta$L93Y_m_BH[df_meta$code == code] + # Stores all the parameters lon = c(lon, lontmp) lat = c(lat, lattmp) @@ -881,17 +882,17 @@ map_panel = function (list_df2plot, df_meta, df_shapefile, idPer_trend=1, # For all stations not to highlight geom_point(data=plot_map, aes(x=lon, y=lat), - shape=21, size=2, stroke=0.5, + shape=21, size=3, stroke=0.5, color='grey97', fill=regimeColor) + geom_text_repel(data=plot_map, aes(x=lon, y=lat, label=code), - segment.colour="grey40", + segment.colour="grey35", segment.size=0.25, min.segment.length=0.25, force=0.4, force_pull=1, - size=2, + size=2.5, color=regimeColor, bg.color="grey97", bg.r=.15) diff --git a/Rcode/plotting/script_layout.R b/Rcode/plotting/script_layout.R index cb0216d6fca8e312ecd26f4696a672f212a9d206..c1fc66a95e0edffee991ff6567a0b80b735496c8 100644 --- a/Rcode/plotting/script_layout.R +++ b/Rcode/plotting/script_layout.R @@ -43,7 +43,7 @@ df_shapefile = ini_shapefile(resources_path, df_meta, fr_shpdir, fr_shpname, bs_shpdir, bs_shpname, sbs_shpdir, sbs_shpname, - cbs_shpdir, cbs_shpname, + cbs_shpdir, cbs_shpname, cbs_coord, rv_shpdir, rv_shpname, show_river=show_river) @@ -74,7 +74,7 @@ if ('station_serie_plot' %in% to_do) { } ### 1.2. Analyses layout _____________________________________________ -if ('station_trend_plot' %in% to_do) { +if ('station_trend_plot' %in% to_do) { layout_panel(to_plot=to_plot_station, map_to_plot=map_to_plot, df_meta=df_meta, diff --git a/Rcode/processing/extract.R b/Rcode/processing/extract.R index 8dc5a3ff39b1d8ce3132473c23b8dfb1d22f84e3..3a43646542c2414732b7317ef04a4a263409a037 100644 --- a/Rcode/processing/extract.R +++ b/Rcode/processing/extract.R @@ -40,6 +40,8 @@ library(tools) library(dplyr) library(officer) +library(sp) # crs +library(sf) # crs ### 1. GENERAL METADATA ON STATION ___________________________________ @@ -692,7 +694,7 @@ ini_shapefile = function (resources_path, df_meta, fr_shpdir, fr_shpname, bs_shpdir, bs_shpname, sbs_shpdir, sbs_shpname, - cbs_shpdir, cbs_shpname, + cbs_shpdir, cbs_shpname, cbs_coord, rv_shpdir, rv_shpname, show_river=TRUE) { Code = levels(factor(df_meta$code)) @@ -719,15 +721,35 @@ ini_shapefile = function (resources_path, df_meta, subBasin = readOGR(dsn=sbs_shppath, verbose=FALSE) df_subBasin = tibble(fortify(subBasin)) + df_codeBasin = tibble() + CodeOk = c() + nShp = length(cbs_shppath) # Hydrological stations basins - codeBasin = readOGR(dsn=cbs_shppath, verbose=FALSE) - shpCode = as.character(codeBasin@data$Code) - df_codeBasin = tibble(fortify(codeBasin)) - groupSample = rle(as.character(df_codeBasin$group))$values - df_codeBasin$code = shpCode[match(df_codeBasin$group, groupSample)] - df_codeBasin = df_codeBasin[df_codeBasin$code %in% Code,] + for (i in 1:nShp) { + codeBasin = readOGR(dsn=cbs_shppath[i], verbose=FALSE) + shpCode = as.character(codeBasin@data$Code) + df_tmp = tibble(fortify(codeBasin)) + groupSample = rle(as.character(df_tmp$group))$values + df_tmp$code = shpCode[match(df_tmp$group, groupSample)] + df_tmp = df_tmp[df_tmp$code %in% Code & + !(df_tmp$code %in% CodeOk),] + CodeOk = c(CodeOk, shpCode[!(shpCode %in% CodeOk)]) + + if (cbs_coord[i] == "L2") { + crs_rgf93 = st_crs(2154) + crs_l2 = st_crs(27572) + sf_loca = st_as_sf(df_tmp[c("long", "lat")], + coords=c("long", "lat")) + st_crs(sf_loca) = crs_l2 + sf_loca = st_transform(sf_loca, crs_rgf93) + sf_loca = st_coordinates(sf_loca$geometry) + df_tmp$long = sf_loca[, 1] + df_tmp$lat = sf_loca[, 2] + } + df_codeBasin = bind_rows(df_codeBasin, df_tmp) + } + df_codeBasin = df_codeBasin[order(df_codeBasin$code),] - # If the river shapefile needs to be load if (show_river) { # Hydrographic network diff --git a/data/AEAG_selection/Q6332510_HYDRO_QJM.txt b/data/AEAG_selection/Q6332510_HYDRO_QJM.txt index 21a70b0dab8881322fe7ab631672c2d1454e9109..2ac271c4f312ed372744270214238cc56a2feb60 100644 --- a/data/AEAG_selection/Q6332510_HYDRO_QJM.txt +++ b/data/AEAG_selection/Q6332510_HYDRO_QJM.txt @@ -13,7 +13,7 @@ ## Territoire : Métropole continentale ## -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ## Définition position stations : 2018 -## Coordonnées station L93 : 405841 ; 6215829 ; 406153 ; 6225881 ; (BANQUE HYDRO ; INRAE Lambert 93 [m]) +## Coordonnées station L93 : 406132 ; 6225883 ; 406153 ; 6225881 ; (BANQUE HYDRO ; INRAE Lambert 93 [m]) ## Coordonnées station L2E : 359684 ; 1779884 ; 359913 ; 1789949 ; (BANQUE HYDRO ; INRAE Lambert 2 étendu [m]) ## Coordonnées station WGS84 : -0.60437 ; 42.98139 ; -0.60618 ; 43.07182 ; (BANQUE HYDRO ; INRAE WGS84 [degrés décimaux]) ## Superficie bassin : 425.00 ; 432.72 ; (BANQUE HYDRO ; INRAE [km2]) diff --git a/main.R b/main.R index 26167b32041b8b0585360a088c623dad0afd882f..aa1fdfcc1896ba9a760be694641e21d2cef239ac 100644 --- a/main.R +++ b/main.R @@ -100,9 +100,9 @@ filename = # 'climate_trend_plot' : Plotting of trend analyses of climate data to_do = c( - # 'station_extraction' - # 'station_trend_analyse' - 'station_trend_plot' + 'station_extraction', + 'station_trend_analyse' + # 'station_trend_plot' ) ## 4. ANALYSIS PARAMETERS ____________________________________________