FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
plotter/data_prep_scripts/styling.R at master · traffordDataLab/plotter · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
traffordDataLab
/
plotter
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
plotter
/
data_prep_scripts
/
styling.R
Copy path
More file actions
More file actions
Latest commit
History
History
History
35 lines (28 loc) · 1.66 KB
Breadcrumbs
plotter
/
data_prep_scripts
/
styling.R
Copy path
File metadata and controls
35 lines (28 loc) · 1.66 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#
# Add styling to GeoJSON features ##
#
load packages ---------------------------
library(
tidyverse
) ; library(
sf
)
#
read data ---------------------------
geojson
<-
st_read(
"
<NAME_OF_FILE>.geojson
"
) %
>
%
#
Un-comment line below to rename the variable names to make the presentation nicer in the styled GeoJSON
#
rename(<NEW NAME 1> = <OLD NAME 1>, <NEW NAME 2> = <OLD NAME 2>, ...)
#
apply styles ---------------------------
geojson_styles
<-
geojson
%
>
%
mutate(
stroke
=
"
#fc6721
"
,
#
example of setting the same value for everything.
#
you can make conditional formatting choices based on categorical data, regular expression match etc. by uncommenting one of the examples below
#
example using an 'if/else' with a regular expression to find the word 'Parking' within the 'name' property
#
if_else(grepl("\\b.*?Parking", name), "#e5c494", "#fc6721"),
#
example using a 'case when' for categorical datasets like green spaces
#
case_when(
#
site_type == "Allotments Or Community Growing Spaces" ~ "#66c2a5",
#
site_type == "Golf Course" ~ "#fc8d62",
#
site_type == "Play Space" ~ "#8da0cb",
#
site_type == "Playing Field" ~ "#e78ac3",
#
site_type == "Public Park Or Garden" ~ "#a6d854",
#
site_type == "Religious Ground and Cemeteries" ~ "#ffd92f",
#
site_type == "Sports" ~ "#e5c494"),
`stroke-width`
=
3
,
`stroke-opacity`
=
1
,
fill
=
stroke
,
`fill-opacity`
=
0.8
)
#
write data ---------------------------
st_write(
geojson_styles
,
"
<NAME_OF_FILE>.geojson
"
)
Back
|
FazBrowse Home
|
New Git URL