Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Maintenance - Mise à jour mensuelle Lundi 6 Février entre 7h00 et 9h00
Open sidebar
UMR-ASTRE
Covid19-Mortality-Visualisation
Commits
7accfd41
Commit
7accfd41
authored
Aug 21, 2020
by
Facundo Muñoz
®️
Browse files
Read world population from world_map in the plan (rather than hidden within a function).
parent
4ead19b1
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/functions.R
View file @
7accfd41
...
...
@@ -48,27 +48,12 @@ stringency <- function(date_range = "2020-01-01/2020-05-31"){
## get country borders for the whole world and get rid of the
## apostrophe in "Cote d'Ivoire"
get_world_map
<-
function
(){
ans
<-
readOGR
(
dsn
=
"./data/moodgaulcountrywithkos2013wpop.gpkg"
,
layer
=
"moodgaulcountrywithkos2013wpop"
)
xname
<-
as.character
(
ans
$
ADM0_NAME
)
pos
<-
grep
(
pattern
=
"Ivoire"
,
x
=
xname
)
xname
[
pos
]
<-
"Cote dIvoire"
ans
$
name
<-
standardise_country_names
(
xname
)
get_world_map
<-
function
(
x
){
ans
<-
readOGR
(
dsn
=
x
)
ans
$
name
<-
standardise_country_names
(
ans
$
ADM0_NAME
)
return
(
ans
)
}
get_world_pop
<-
function
(){
ans
<-
readOGR
(
dsn
=
"./data/moodgaulcountrywithkos2013wpop.gpkg"
,
layer
=
"moodgaulcountrywithkos2013wpop"
)
xname
<-
as.character
(
ans
$
ADM0_NAME
)
pos
<-
grep
(
pattern
=
"Ivoire"
,
x
=
xname
)
xname
[
pos
]
<-
"Cote dIvoire"
ans
$
name
<-
standardise_country_names
(
xname
)
return
(
data.frame
(
name
=
ans
$
name
,
pop
=
ans
$
TOTPOP
)
)
}
#' Simplify a vector layer
geosimplify
<-
function
(
x
)
{
...
...
src/plan.R
View file @
7accfd41
...
...
@@ -56,7 +56,6 @@ plan <- drake_plan(## raw_data = read_excel(
## check.names = F,
## quote = "\""
## ),
world_population
=
get_world_pop
(),
## ECDC Covid19 geographic distribution data
last_day
=
Sys.Date
()
-
1
,
...
...
@@ -88,7 +87,17 @@ plan <- drake_plan(## raw_data = read_excel(
## CARTOGRAPHY ---------------------------------------------------
world_map
=
get_world_map
(),
## Coordinate Reference Systems
wgs84
=
CRS
(
"+proj=longlat +ellps=WGS84"
,
doCheckCRSArgs
=
FALSE
),
merc
=
CRS
(
"+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs"
,
doCheckCRSArgs
=
FALSE
),
eust
=
"MOOD has received funding from the EU Horizon 2020 Research and Innovation programme under grant agreement No 874850."
,
## Country borders and population data
world_map
=
get_world_map
(
ile_in
(
"data/moodgaulcountrywithkos2013wpop.gpkg"
)),
## GIS vector layer for European countries (EU 27 + UK + EFTA +
## candidate countries + non-EU countries). Source GADM.org
...
...
@@ -108,6 +117,15 @@ plan <- drake_plan(## raw_data = read_excel(
## DERIVED DATA ----------------------------------------
world_population
=
world_map
%>%
as_tibble
%>%
mutate
(
name
=
standardise_country_names
(
ADM0_NAME
)
)
%>%
select
(
name
,
pop
=
TOTPOP
)
%>%
filter
(
pop
>
0
),
## ## Deaths by country and date
## deaths_by_ctry_dt =
## covid %>%
...
...
@@ -116,20 +134,7 @@ plan <- drake_plan(## raw_data = read_excel(
## ungroup() %>%
## mutate(date = as.Date(date)),
## Population counts in thousands of people
pop_countries_2020
=
subset
(
world_population
,
subset
=
name
%in%
xeurope_countries
$
name
),
## ## today (ANSI)
## tod = format(Sys.Date(), "%Y%m%d"),
## Coordinate Reference Systems
wgs84
=
CRS
(
"+proj=longlat +ellps=WGS84"
,
doCheckCRSArgs
=
FALSE
),
merc
=
CRS
(
"+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs"
,
doCheckCRSArgs
=
FALSE
),
## Lock-down dates and population counts by country of the european
## Lock-down dates and population counts by country of the european
## and neighbouring countries
xeurope_countries
=
enframe
(
...
...
@@ -155,7 +160,6 @@ plan <- drake_plan(## raw_data = read_excel(
by
=
"name"
),
eust
=
"MOOD has received funding from the EU Horizon 2020 Research and Innovation programme under grant agreement No 874850."
,
report_euro_html
=
rmarkdown
::
render
(
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment