In this video, I will show you how to make before/after swipe maps of nighttime lights using shiny in R. Swipe maps are a great way to compare two different maps and see how they change over time or space. We will use the VIIRS data from the Earth Observation Group (EOG) to create the swipe map of Ukraine's nighttime lights before and after the onset of war in 2022.
0:00 Prologue
01:11 Intro
01:59 Load libraries
04:55 Ukraine country shapefile
05:55 Earth observation group website
08:39 Download nightlight data
10:14 Enlist nightlight rasters
10:57 Load global nightlight data
12:37 Crop Ukraine extent
15:06 Reproject data
17:00 Remove zeros and subzeros
18:23 Raster to dataframe
21:50 Color palette
23:05 Set dataframe names
24:13 Create maps
31:04 Save maps
33:28 Move maps to shiny directory
37:32 Fetch CSS, JS and HTMLcode
38:55 Modify CSS code
42:22 Change JS code
44:03 Shiny app
46:52 Open output in browser
47:05 Swipe map
47:37 Closing
Check the full code in my GitHub repo:
https://github.com/milos-agathon/swip...
Follow my work on Instagram:
/ milos_makes_maps
Let's connect on X:
/ milos_agathon
If you like my work, consider buying me a coffee:
https://www.buymeacoffee.com/milospop...
Music credits:
---------------------------------
"Tokyo Music Walker - Way Home" is under a Creative Commons (CC-BY) license.
/ @tokyomusicwalker4038
Music promoted by BreakingCopyright: https://bit.ly/way-home-song