library(terra) # For raster maps handlinglibrary(sf) # For spatial objectslibrary(tidyverse) # Data wranglinglibrary(rayshader) # Rayshader Mapslibrary(elevatr) # Get elevation matrices for plottinglibrary(here) # For locating working directorylibrary(showtext) # Using Fonts More Easily in R Graphslibrary(ggimage) # Using Images in ggplot2library(fontawesome) # Social Media iconslibrary(ggtext) # Markdown Text in ggplot2
Getting the Data on Power Plants in India
Code
# The URL of the databaseurl <-"https://wri-dataportal-prod.s3.amazonaws.com/manual/global_power_plant_database_v_1_3.zip"# Saving a filename for downloading the data intofilename <-basename(url)download.file(url = url,destfile =here("data", "power_plants", filename),mode ="wb")unzip(here("data", "power_plants", filename))list.files(here("data", "power_plants"))
# Creating a matrix of elevation pointselmat <- elev_lambert |> rayshader::raster_to_matrix()# Coverting as below sea level points to sea levelelmat[elmat <0] <-0# Removing missing values of elevation and replacing# them with minimum elevation valueelmat[is.na(elmat)] <-min( elmat,na.rm = T)
Selecting Power Plants that are within India’s borders