Skip to content

Commit

Permalink
docs(vignette niveaux nappes): add plot popup on the map
Browse files Browse the repository at this point in the history
Refs #42
  • Loading branch information
DDorch committed Feb 22, 2024
1 parent a26fe2d commit 5a08976
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions vignettes/example_niveaux_nappes_api.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -148,28 +148,36 @@ ggplot(data = yearly_mean_water_table_level,

# Mapping

The 'stations' dataframe is transformed into a `sf` geographical object.
The `stations` data.frame is transformed into a `sf` geographical object.

```{r}
stations_geo <- stations %>%
st_as_sf(coords = c("x", "y"),
crs = 4626)
```

Then they are mapped using the `mapview` R package.
We create a plot for each station ready to be displayed as map "pop-up".

```{r, fig.width = 8, fig.height = 8}
mapview(stations_geo,
map.types = c(
"OpenStreetMap",
"Esri.WorldShadedRelief",
"OpenTopoMap"
))
```{r}
p <- lapply(unique(yearly_mean_water_table_level$code_bss),
function(x) {
ggplot(data = yearly_mean_water_table_level %>% filter(code_bss == x),
aes(x = year,
y = yearly_mean_water_table_level)) +
geom_line() +
labs(title = x)
})
```

Then they are mapped using the `mapview` R package. Click on a spot to popup the
plot.






```{r, out.width = "100%", fig.asp = 1}
mapview(
stations_geo,
map.types = c("OpenStreetMap",
"Esri.WorldShadedRelief",
"OpenTopoMap"),
popup = leafpop::popupGraph(p)
)
```

0 comments on commit 5a08976

Please sign in to comment.