Skip to content

Commit

Permalink
Change proj to wintri
Browse files Browse the repository at this point in the history
Why

* Wintri is available for older proj version

How

* Recreate internal spatial dataset
* Modify vignette and tmap st_transform()
* Fix doc warnings
* Prepare deliverables

issue #36
  • Loading branch information
statnmap committed Sep 30, 2021
1 parent 84dacb3 commit 8454610
Show file tree
Hide file tree
Showing 26 changed files with 1,098 additions and 4,917 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ creds.R
dev/00-fill-database.html
.Renviron
data-raw/db
deliverables
8 changes: 4 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,18 @@ Imports:
maps (>= 3.3.0),
patchwork (>= 1.1.1),
purrr (>= 0.3.4),
rmapshaper (>= 0.4.5),
RPostgres (>= 1.3.3),
sf (>= 1.0.2),
shinipsum (>= 0.1.0),
shiny (>= 1.6.0),
shinythemes (>= 1.2.0),
tmap (>= 3.3.2),
utils,
zeallot (>= 0.1.0),
w3css (>= 0.0.0.9002),
sf (>= 1.0.2),
rmapshaper (>= 0.4.5),
dbplyr (>= 2.1.1)
zeallot (>= 0.1.0)
Suggests:
dbplyr,
DiagrammeR (>= 1.0.6.1),
DiagrammeRsvg (>= 0.1),
knitr (>= 1.34),
Expand Down
1 change: 1 addition & 0 deletions R/fct_db.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ connect <- function(
#' @export
#'
#' @examples
#' get_con()
get_con <- function(
session = shiny::getDefaultReactiveDomain()
){
Expand Down
3 changes: 3 additions & 0 deletions R/fct_species.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ get_active_species <- function(
#' @export
#'
#' @examples
#' if (interactive()){
#' get_conservation_status()
#' }
get_conservation_status <- function(
species_id,
con
Expand Down
10 changes: 5 additions & 5 deletions R/mod_a_fourth.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ mod_fourth_server <- function(id, r = r){

output$raster <- tmap::renderTmap({
req(loco$species)

tm_draw(
species_latin_name = loco$species,
spatial_type = input$square_or_division,
Expand All @@ -92,10 +92,10 @@ mod_fourth_server <- function(id, r = r){
ices_geom = golem::get_golem_options("ices_geom")
)

}) %>% bindCache({
loco$species
input$square_or_division
})
}) # %>% bindCache({
# loco$species
# input$square_or_division
# })

observeEvent( loco$species , {
req(loco$species)
Expand Down
1 change: 0 additions & 1 deletion R/mod_a_fourth_fct_map.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#' @import sf
#' @import tmap
#'
#' @examples
tm_draw <- function(
species_latin_name,
spatial_type,
Expand Down
2 changes: 1 addition & 1 deletion R/mod_c_second.R
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ mod_second_server <- function(id, r = r){
)),
aes(fill = region)
) +
coord_map() +
# coord_map() +
theme_void() +
guides(
fill = FALSE
Expand Down
2 changes: 1 addition & 1 deletion R/mod_d_third.R
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ mod_third_server <- function(id, r = r){
)),
aes(fill = region)
) +
coord_map() +
# coord_map() +
theme_void() +
guides(
fill = FALSE
Expand Down
1 change: 0 additions & 1 deletion R/mod_species.R
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ mod_species_server <- function(id, r, entry = "species"){
selected = ''
)
})

})
}

Expand Down
1 change: 1 addition & 0 deletions R/run_app.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#' @importFrom shiny shinyApp
#' @importFrom golem with_golem_options
#' @importFrom zeallot %<-%
#'
run_app <- function(
onStart = NULL,
options = list(),
Expand Down
4 changes: 2 additions & 2 deletions R/utils_helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ get_dt_lg <- function(lg){
#' @return
#' @export
#'
#' @examples
generate_datasets <- function(
con
){
Expand Down Expand Up @@ -84,7 +83,8 @@ generate_datasets <- function(
con,
query = "SELECT * FROM diadesatlas.v_ices_geom;"
) %>%
sf::st_transform("+proj=eqearth +wktext") %>%
# sf::st_transform("+proj=eqearth +wktext") %>%
sf::st_transform("+proj=wintri") %>%
rmapshaper::ms_simplify()

species_list <- con %>%
Expand Down
14 changes: 13 additions & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ The apps needs to connect to a db.

It can be set via :

```{r eval = FALSE}
```{r eval=FALSE}
golem::amend_golem_config(
"POSTGRES_DBNAME",
"diades"
Expand All @@ -60,6 +60,18 @@ Sys.setenv("POSTGRES_PASS" = "thinkrpassword")

For dev purpose, please refer to the doc in the diadesdata repo on ThinkR's forge (restricted access).

Verify connexion works
```{r, eval=FALSE}
pkgload::load_all()
session <- new.env()
connect(session)
con <- get_con(session)
DBI::dbListTables(con)
DBI::dbDisconnect(con)
```


# Dev - vignettes

Vignettes are compiled manually by developers.
Expand Down
14 changes: 11 additions & 3 deletions data-raw/bb-page1-catch-bycatch.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ file = here::here(file.path("vignettes", vignette_file))
```{r setup}
# Sys.setenv("POSTGRES_USER" = "diadesatlas_owner")
# Sys.setenv("POSTGRES_PASS" = "thinkrpassword")
pkgload::load_all()
pkgload::load_all(here::here())
library(dplyr)
session <- new.env()
connect(session)
Expand Down Expand Up @@ -109,7 +109,8 @@ catchment_geom <- st_read(
con,
query = "SELECT * FROM diadesatlas.v_basin vb"
) %>%
rmapshaper::ms_simplify()
rmapshaper::ms_simplify() %>%
st_transform("+proj=wintri")
dataALL <- dbGetQuery(
con,
Expand All @@ -122,7 +123,8 @@ ices_geom <- st_read(
con,
query = "SELECT * FROM diadesatlas.v_ices_geom;"
) %>%
st_transform("+proj=eqearth +wktext") %>%
# st_transform("+proj=eqearth +wktext") %>%
st_transform("+proj=wintri") %>%
rmapshaper::ms_simplify()
Expand Down Expand Up @@ -169,3 +171,9 @@ tm_draw(
)
```

## Disconnect db
```{r}
DBI::dbDisconnect(con)
```

3 changes: 2 additions & 1 deletion data-raw/frontiers.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ states = c("Portugal", "Spain","France", "United Kingdom", "Ireland", "United Ki
frontiers <- worldMap %>% select(NAME, geometry) %>% filter(NAME %in% states)

bbox <- st_bbox(c(xmin = -17.5, xmax = 19, ymax = 36, ymin = 62), crs = st_crs(4326))
world_map_crs <- "+proj=eqearth +wktext"
# world_map_crs <- "+proj=eqearth +wktext"
world_map_crs <- "+proj=wintri"

frontiers <- frontiers %>%
st_transform(world_map_crs) %>%
Expand Down
Binary file modified data/frontiers.rda
Binary file not shown.
Binary file modified data/tm_frontiers.rda
Binary file not shown.
7 changes: 6 additions & 1 deletion dev/02_dev.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ usethis::use_package("sf")

# Before sending to git external server
# _deps
attachment::att_amend_desc(extra.suggests = c("pkgload", "DiagrammeR", "DiagrammeRsvg"))
renv::install("ThinkR-open/attachment")
# [-] 7 package(s) removed: ggplot2, magrittr, maps, RPostgres, shinythemes, zeallot, dbplyr.

attachment::att_amend_desc(
extra.suggests = c("pkgload", "DiagrammeR", "DiagrammeRsvg", "dbplyr"))

# _renv
custom_packages <- setdiff(
c(attachment::att_from_description(),
Expand Down
55 changes: 50 additions & 5 deletions dev/deliverables.R
Original file line number Diff line number Diff line change
@@ -1,13 +1,35 @@
# Deliverables ====
dir.create("deliverables")
usethis::use_build_ignore("deliverables")
usethis::use_git_ignore("deliverables")

## _pkgdown ----
# _Compile manual vignette
rmarkdown::render(input = here::here("data-raw/aa-data-exploration-and-preparation.Rmd"),
output_format = "rmarkdown::html_vignette",
output_options = list(toc = TRUE),
output_file = here::here("vignettes/explo-manual.html"))
# See readme
rstudioapi::navigateToFile("README.Rmd")

## Upgrade version Number in DESCRIPTION
## Create a commit for the version
## Add tag on version commit

## _covr ----
x <- covr::package_coverage()
# Change {my-project}
covr::report(x, file = "deliverables/codecoverage/listofcodes-codecoverage-full-report.html")


## Update description files in app
chameleon::create_pkg_biblio_file(
to = "html",
out.dir = "inst/app/www/about", edit = FALSE)
chameleon::create_pkg_desc_file(
source = c("archive"),
out.dir = "inst/app/www/about", to = "html", edit = FALSE)

## _add covrpage ----
# remotes::install_github("metrumresearchgroup/covrpage")
covrpage::covrpage(vignette = TRUE)
file.remove("tests/README.md")

# remotes::install_github("ThinkR-open/chameleon")
# remotes::install_github("ThinkR-open/thinkrtemplate")
Expand Down Expand Up @@ -62,4 +84,27 @@ rsconnect::deployApp(
setwd(origwd)


# Clone on Irstea GitLab
# Deploy App on rsconnect ----
# Deploy app on connect
appFiles <- list.files(".", recursive = TRUE)
appFiles <- appFiles[!grepl(".Rprofile|renv|rstudio_|deliverables|dev|data-raw|docker", appFiles)]

rsconnect::writeManifest(appFiles = appFiles)

# Deploy App on rsconnect manually
rsconnect::accounts()
account_name <- rstudioapi::showPrompt("Rsconnect account", "Please enter your username:", "name")
account_server <- rstudioapi::showPrompt("Rsconnect server", "Please enter your server name:", "1.1.1.1")

appFiles <- list.files(".", recursive = TRUE)
appFiles <- appFiles[!grepl(".Rprofile|renv|rstudio_|deliverables|dev|data-raw|docker", appFiles)]
rsconnect::deployApp(
".", # the directory containing the content
appFiles = appFiles, # the list of files to include as dependencies (all of them)
# appId = 478,
appName = "app-diades.atlas", # name of the endpoint (unique to your account on Connect)
appTitle = "app-diades.atlas", # display name for the content
account = account_name, # your Connect username
server = account_server # the Connect server, see rsconnect::accounts()
)

6 changes: 4 additions & 2 deletions dev/tab1.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ states = c("Portugal", "Spain","France", "United Kingdom", "Ireland", "United Ki
'Albania', 'Bosnia and Herz.', 'Serbia', 'Montenegro', 'Macedonia', 'Kosovo',
'Tunisia', 'Libya' , 'Algeria' , 'Morocco' )
world_map_crs <- "+proj=eqearth +wktext"
# world_map_crs <- "+proj=eqearth +wktext"
world_map_crs <- "+proj=wintri"
frontiers <- worldMap %>%
select(NAME, geometry) %>%
filter(NAME %in% states) %>%
Expand Down Expand Up @@ -268,7 +269,8 @@ ices_geom <- st_read(
con,
query = "SELECT * FROM diadesatlas.v_ices_geom;"
) %>%
st_transform("+proj=eqearth +wktext") %>%
# st_transform("+proj=eqearth +wktext") %>%
st_transform("+proj=wintri") %>%
rmapshaper::ms_simplify()
tm_draw(
Expand Down
2 changes: 1 addition & 1 deletion inst/golem-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ default:
production:
app_prod: yes
dev:
golem_wd: !expr here::here()
golem_wd: /mnt/Data/ThinkR/Gitlab_Forge/ThinkR/Missions/diades.atlas
3 changes: 3 additions & 0 deletions man/get_con.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions man/get_conservation_status.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8454610

Please sign in to comment.