https://github.com/USAID-OHA-SI/gisr
OHA Geospatial Analytics Utilities
https://github.com/USAID-OHA-SI/gisr
gis map r
Last synced: 4 months ago
JSON representation
OHA Geospatial Analytics Utilities
- Host: GitHub
- URL: https://github.com/USAID-OHA-SI/gisr
- Owner: USAID-OHA-SI
- License: mit
- Created: 2020-06-13T22:39:53.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2024-02-09T19:10:41.000Z (about 1 year ago)
- Last Synced: 2024-06-04T23:02:32.099Z (10 months ago)
- Topics: gis, map, r
- Language: R
- Homepage: https://usaid-oha-si.github.io/gisr/
- Size: 6.15 MB
- Stars: 2
- Watchers: 5
- Forks: 0
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - USAID-OHA-SI/gisr - OHA Geospatial Analytics Utilities (R)
README
# gisr
Geospatial Analytics Utilities
[](https://github.com/USAID-OHA-SI/gisr/actions)
[](https://usaid-oha-si.r-universe.dev/gisr)
[](https://lifecycle.r-lib.org/articles/stages.html#stable)
[](https://usaid-oha-si.r-universe.dev/)## Installation
`gisr` is not on CRAN, so you will have to install it directly from [rOpenSci](https://usaid-oha-si.r-universe.dev/packages) or [GitHub](https://github.com/USAID-OHA-SI/) using the code found below.
``` r
## SETUP
# Pre-requisits - gisr user rnaturalearthdata and rnaturalearthhires
remotes::install_github("ropensci/rnaturalearth")
remotes::install_github("ropensci/rnaturalearthhires")#install from rOpenSci
install.packages('gisr', repos = c('https://usaid-oha-si.r-universe.dev', 'https://cloud.r-project.org'))
#alt: install from GitHub using pak
#install.packages("pak")
#pak::pak("USAID-OHA-SI/gisr")
#load the package
library(gisr)## LIST TYPES OF STYLES INCLUDED WITH PACKAGE
ls("package:gisr")
```
## Get administrative boundaries
Admin boundaries + neighbor countries data from [Natural Earth Data](https://www.naturalearthdata.com/)```{r}
library(tidyverse)
library(sf)
library(gisr)zambia0 <- get_admin0("Zambia")
zambia1 <- get_admin1("Zambia")zambia_neighbors <- geo_neighbors("Zambia")
ggplot(data = zambia_neighbors) +
geom_sf(fill = NA) +
geom_sf(data = zambia1, fill = gray(.92), lty = "dashed") +
geom_sf(data = zambia0, fill = NA) +
geom_sf_text(aes(label = sovereignt), size = 3) +
theme_void()
```## Plot a terrain map
Create a terrain map with vector + raster data from local DEM Tiff file
```{r}
library(tidyverse)
library(sf)
library(gisr)dem_dir <- "./GIS"
z_map1 <- terrain_map("Zambia", terr_path = dir_terr)
print(z_map1)
z_map2 <- terrain_map("Zambia", terr_path = dir_terr, add_neighbors = TRUE)
print(z_map2)```
## Plot an admin map
Create an administrative map with vector data from RNaturalEarth
```{r}
library(systemfonts)
library(tidyverse)
library(sf)
library(glitr)
library(gisr)z_map1 <- admins_map("Zambia")
print(z_map1)
z_map2 <- admins_map("Zambia", add_neighbors = TRUE)
print(z_map2)```
## Apply SI Style Guide to maps
Create an administrative map with vector data from RNaturalEarth and apply SI Style
```{r}
library(systemfonts)
library(tidyverse)
library(gisr)
library(sf)
library(glitr)sfdf <- gisr::get_admin1("Nigeria") %>%
select(name) %>%
mutate(value = runif(nrow(.), 0, 1))ggplot() +
geom_sf(data = sfdf,
aes(fill = value),
color = grey10k,
size = .1) +
scale_fill_si(palette = "genoas",
discrete = FALSE,
limits = c(0, 1),
labels = scales::percent) +
labs(title = "NIGERIA - % OF PLHIV BY STATE",
subtitle = "States from XYZ Region are the most hit by HIV/AIDS",
caption = base::paste0("Produced by OHA/SIEI/SI, ON ", base::Sys.Date())) +
si_style_map()
```
---
*Disclaimer: The findings, interpretation, and conclusions expressed herein are those of the authors and do not necessarily reflect the views of United States Agency for International Development. All errors remain our own.*