Commit 0dcc8750 authored by Grelot Frederic's avatar Grelot Frederic :swimmer_tone5:
Browse files

Ajustement de Fred

- data.R
	- meilleure descsirption du dataset so_ii_hydro
- so_ii_hydro
	- simpliciation du dataset
- map_so_ii
	- harmonisation du code
	- manque légende
Showing with 72 additions and 34 deletions
+72 -34
......@@ -71,4 +71,12 @@
#' within the so-ii perimeter.
#'
#' @format sf data.frame 125 rows, 4 variables
#' \describe{
#' \item{id}{id, from BD TOPAGE (corresponding to CdOh)}
#' \item{name}{character, name of the river or part of the river in BD
#' TOPAGE}
#' \item{degre}{character, level of detail to plot the hydrographic network}
#' }
#'
#' @source \url{http://bdtopage.eaufrance.fr/page/objectifs}
"so_ii_hydro"
......@@ -6,12 +6,13 @@
#' @param bar logical, should a bar be plotted
#' @param path character, the name of the file to save the plot
#' @param gaspar_year character, the year chosen for gaspar theme
#' @param hydro_detail character, the niveau of detail in the representation of the hydrographic network
#' @param detail character, detail for theme, depends on theme
#' @param ... some parameters that will be used by plot (from sf)
#'
#' @return Nothing useful.
#'
#' @details hydro_detail takes values "1", "2", "3" or "canal"
#' @details
#' For theme "hydro" detail takes values "1", "2", "3" or "canal"
#'
#' @export
#'
......@@ -27,13 +28,14 @@
map_so_ii = function(
dataset,
dataset_legend = NULL,
theme = c("clc", "gaspar", "hydro"),
theme = c("", "clc", "gaspar", "hydro"),
bar = TRUE,
path = NULL,
gaspar_year,
hydro_detail,
detail,
...
) {
theme = match.arg(theme)
if (!is.null(path)) {
switch(
......@@ -79,28 +81,23 @@ map_so_ii = function(
}
if ("hydro" %in% theme) {
if(missing(hydro_detail)) {
hydro_detail = "0"
if (missing(detail)) {
detail = "0"
}
if(hydro_detail == "canal") {
detail = match.arg(detail, choices = c("0", "1", "2", "3", "canal"))
if (detail == "canal") {
selection = geau::so_ii_hydro[["degre"]] == detail
geometry = geau::so_ii_hydro[["geometry"]][selection]
color = scales::alpha("red", .3)
so_ii_hydro_toplot = geau::so_ii_hydro[["geometry"]][geau::so_ii_hydro[["degre"]] == hydro_detail]
lwd = 1
} else {
#color = "#dbe8f0"
selection = geau::so_ii_hydro[["degre"]] <= detail
geometry = geau::so_ii_hydro[["geometry"]][]
color = scales::alpha("blue", .3)
so_ii_hydro_toplot = geau::so_ii_hydro[["geometry"]][geau::so_ii_hydro[["degre"]] <= hydro_detail]
lwd = 4 - as.numeric(geau::so_ii_hydro[["degre"]][geau::so_ii_hydro[["degre"]] <= hydro_detail])
lwd = 4 - as.numeric(geau::so_ii_hydro[["degre"]][selection])
}
plot(
so_ii_hydro_toplot,
col = color,
lwd = lwd,
add=TRUE
)
plot(geometry, col = color, lwd = lwd, add = TRUE)
}
plot(dataset[["geometry"]], add = TRUE, ...)
......
# code to prepare `so_ii_hydro` dataset goes here
selection = c("gid", "CdOH", "TopoOH")
version = current_version("data-common/so-ii/topage",
pattern = "^[0-9]")
so_ii_hydro = sf::st_read(file.path(version, "cours-eau-so-ii.shp"))[selection]
so_ii_hydro = sf::st_transform(so_ii_hydro, sf::st_crs(geau::so_ii_limit))
selection = c("CdOH", "TopoOH")
file_dir = current_version(
"data-common/so-ii/topage",
pattern = "^[0-9-]+$"
)
so_ii_hydro = sf::st_read(file.path(file_dir, "cours-eau-so-ii.shp"))
so_ii_hydro = sf::st_transform(
so_ii_hydro[selection],
sf::st_crs(geau::so_ii_limit)
)
names(so_ii_hydro) = c("id", "name", "geometry")
classif_hydro = read.csv2(
classification = read.csv2(
current_version("data-common/so-ii/topage", pattern = "courseau"),
colClasses = "character",
row.names = 1
)
colClasses = "character"
)[c("id", "name", "degre")]
so_ii_hydro = merge(
so_ii_hydro, classif_hydro,
by.x = selection,
by.y = c("id_1", "id_2", "cours_eau")
)
so_ii_hydro = merge(so_ii_hydro, classification)
# updating datasets
......
No preview for this file type
......@@ -8,10 +8,11 @@
map_so_ii(
dataset,
dataset_legend = NULL,
theme = c("clc", "gaspar"),
theme = c("", "clc", "gaspar", "hydro"),
bar = TRUE,
path = NULL,
gaspar_year,
detail,
...
)
}
......@@ -28,6 +29,8 @@ map_so_ii(
\item{gaspar_year}{character, the year chosen for gaspar theme}
\item{detail}{character, detail for theme, depends on theme}
\item{...}{some parameters that will be used by plot (from sf)}
}
\value{
......@@ -36,6 +39,9 @@ Nothing useful.
\description{
Plot a thematic map of so-ii
}
\details{
For theme "hydro" detail takes values "1", "2", "3" or "canal"
}
\examples{
\dontrun{
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/data.r
\docType{data}
\name{so_ii_hydro}
\alias{so_ii_hydro}
\title{Hydrographic network within the so-ii perimeter}
\format{
sf data.frame 125 rows, 4 variables
\describe{
\item{id}{id, from BD TOPAGE (corresponding to CdOh)}
\item{name}{character, name of the river or part of the river in BD
TOPAGE}
\item{degre}{character, level of detail to plot the hydrographic network}
}
}
\source{
\url{http://bdtopage.eaufrance.fr/page/objectifs}
}
\usage{
so_ii_hydro
}
\description{
A dataset containing the official hydrographic network from the BD TOPAGE
within the so-ii perimeter.
}
\keyword{datasets}
Supports Markdown
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