Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
earth-in-flux
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Water Mission Area
VizLab
earth-in-flux
Commits
33ea32a0
Commit
33ea32a0
authored
2 weeks ago
by
Vaarre-Lamoureux, Kaysa S
Browse files
Options
Downloads
Patches
Plain Diff
create thumbnail for findex global maps
parent
58188e2b
No related branches found
No related tags found
1 merge request
!92
Tweaks to findex global maps page
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
findex/_targets.R
+13
-0
13 additions, 0 deletions
findex/_targets.R
findex/src/plot_utils.R
+39
-0
39 additions, 0 deletions
findex/src/plot_utils.R
src/assets/images/threat_by_basin_thumbnail.png
+0
-0
0 additions, 0 deletions
src/assets/images/threat_by_basin_thumbnail.png
with
52 additions
and
0 deletions
findex/_targets.R
+
13
−
0
View file @
33ea32a0
...
...
@@ -277,6 +277,19 @@ p3 <- list(
knitr
::
plot_crop
(
"../src/assets/images/all_threat_by_basin.png"
)
},
format
=
"file"
),
tar_target
(
p3_top_threat_thumbnail
,
top_threat_thumbnail
(
in_dat
=
p2_mean_weighted_threats
,
threat_pal
=
p2_viz_config
,
hybas_habitat_types
=
p2_hybas_habitat_types_sf
,
proj
=
p1_proj
,
threat_category
=
"none"
,
height
=
6
,
width
=
6
,
dpi
=
300
,
out_file
=
"../src/assets/images/threat_by_basin_thumbnail.png"
),
format
=
"file"
)
# tar_target(
# p3_top_threat_legend_png,
...
...
This diff is collapsed.
Click to expand it.
findex/src/plot_utils.R
+
39
−
0
View file @
33ea32a0
...
...
@@ -313,3 +313,42 @@ save_top_threat_legend <- function(plot, dpi, out_file){
knitr
::
plot_crop
(
out_file
)
}
top_threat_thumbnail
<-
function
(
in_dat
,
threat_pal
,
hybas_habitat_types
,
proj
,
threat_category
,
height
,
width
,
dpi
,
out_file
){
# these coordinates are NAD83 coordinates that correspond to "EPSG:4269", so will only work with the other data if they are also in "EPSG:4269"
bbox
<-
st_bbox
(
c
(
xmin
=
-25
,
xmax
=
60
,
ymin
=
-35
,
ymax
=
40
))
# get bbox of projected area of interest
if
(
!
(
proj
==
"EPSG:4269"
))
{
bbox
<-
sf
::
st_as_sfc
(
bbox
)
|>
st_as_sf
(
crs
=
"EPSG:4269"
)
|>
sf
::
st_transform
(
crs
=
proj
)
|>
sf
::
st_bbox
()
}
# call custom plotting function
threat_map
<-
top_threat_plot
(
in_dat
=
in_dat
,
threat_pal
=
threat_pal
,
hybas_habitat_types
=
hybas_habitat_types
,
proj
=
proj
,
threat_category
=
threat_category
)
+
# crop for thumbnail
coord_sf
(
xlim
=
c
(
bbox
[
'xmin'
],
bbox
[
'xmax'
]),
ylim
=
c
(
bbox
[
'ymin'
],
bbox
[
'ymax'
]),
expand
=
F
)
+
# white background and add margin
theme
(
legend.position
=
"none"
,
plot.background
=
element_rect
(
fill
=
"white"
,
color
=
NA
),
panel.background
=
element_rect
(
fill
=
"white"
,
color
=
NA
),
plot.margin
=
margin
(
t
=
2
,
r
=
2
,
b
=
2
,
l
=
2
,
unit
=
"cm"
))
# save in square ratio
ggsave
(
out_file
,
threat_map
,
height
=
height
,
width
=
width
,
dpi
=
dpi
)
}
This diff is collapsed.
Click to expand it.
src/assets/images/threat_by_basin_thumbnail.png
0 → 100644
+
0
−
0
View file @
33ea32a0
361 KiB
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment