Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/AustralianAntarcticDivision/SOmap
Southern Ocean round maps
https://github.com/AustralianAntarcticDivision/SOmap
Last synced: about 1 month ago
JSON representation
Southern Ocean round maps
- Host: GitHub
- URL: https://github.com/AustralianAntarcticDivision/SOmap
- Owner: AustralianAntarcticDivision
- Fork: true (Maschette/SOmap)
- Created: 2018-10-28T23:06:11.000Z (about 6 years ago)
- Default Branch: main
- Last Pushed: 2024-09-02T10:25:23.000Z (4 months ago)
- Last Synced: 2024-10-29T20:35:51.554Z (2 months ago)
- Language: R
- Homepage: https://australianantarcticdivision.github.io/SOmap/
- Size: 329 MB
- Stars: 24
- Watchers: 8
- Forks: 6
- Open Issues: 16
-
Metadata Files:
- Readme: README.Rmd
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- open-sustainable-technology - SOmap - The goal of this package is to make publication quality round Southern Ocean maps in polar projections with little effort. (Cryosphere / Sea Ice)
README
---
output: github_document
editor_options:
chunk_output_type: console
---[![R-CMD-check](https://github.com/AustralianAntarcticDivision/SOmap/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/AustralianAntarcticDivision/SOmap/actions/workflows/R-CMD-check.yaml)
```{r setup, include = FALSE}
knitr::opts_chunk$set(collapse = TRUE, comment = "#>", warning = FALSE,
fig.path = "man/figures/README-", fig.height = 8, fig.width = 8, dpi = 300, out.width = "100%")```
# SOmap
The goal of SOmap is to make publication quality round Southern Ocean maps in polar projections with little effort. This package is still very much a work in progress contact me with any questions or suggestions.
## Installation
The development version from [GitHub](https://github.com/AustralianAntarcticDivision/SOmap) with:```{r eval = FALSE}
install.packages("SOmap", repos = c(SCAR = "https://scar.r-universe.dev",
CRAN = "https://cloud.r-project.org"))## or
## install.packages("remotes") ## if needed
remotes::install_github("AustralianAntarcticDivision/SOmap")```
## ExampleTo make a simple map you can use the following function; use `? SOmap` to see all the options for modifying layers.
```{r examplemap, message = FALSE, warning = FALSE}
library(SOmap)
SOmap()
```There is also `SOmanagement()` which provides management layers for the Southern Ocean and `SOleg()` which gives custom rounded legends for added map layers.
```{r management}
## custom colours
spiritedMedium <- colorRampPalette(c("#4D4140", "#596F7E", "#168B98",
"#ED5B67", "#E27766", "#DAAD50", "#EAC3A6"))
spirited <- spiritedMedium(80)SOmap(trim = -40)
## add an example sea ice raster, which is bundled with SOmap
plot(ice, col = spirited, add = TRUE, legend = FALSE, alpha = 0.95)
SOleg(ice, position = "topright", col = spirited, ticks = 6,
tlabs = c("0", "20", "40", "60", "80", "100"),
trim = -40, label = "Sea Ice", type = "continuous")## add the exclusive economic zones management layer
SOmanagement(eez = TRUE)
```Curved legends can be either continuous (as above) or discrete.
```{r, echo=FALSE}
centroids<-data.frame(pop = structure(1:8, .Label = c("1", "2", "3","4", "5", "6", "7", "8"), class = "factor"), lon = c(7.36921794861538, 76.0083253690476, 88.1945661849315, 134.966444407778, -178.009759,-164.882487618519, -80.8082988510345, -30.1700251934884), lat = c(-63.6191794892308,-53.1358253619048, -65.0577956330822, -65.0150925555556, -72.891637562451, -63.3747530640741, -68.9245057482759, -60.3177015502326))coordinates(centroids)<-c("lon", "lat")
projection(centroids)<- "+proj=longlat +datum=WGS84"
centroids<-spTransform(centroids,CRS(projection(SOmap::Bathy)))
``````{r SOleg}
spirited8 <- spiritedMedium(8)SOmap()
plot(centroids, col=spirited8, add=TRUE, pch=19)
SOleg(centroids,position = "topright", col = spirited8, ticks = 8,
tlabs =1:8, label = "Centroids", type = "discrete")```
An **automatic** plot function `SOmap_auto()` will take any data in the form of longitude and latitude vectors and create a guess at a map.
```{r automap, fig.height = 5, fig.width = 5}
ellie <- SOmap_data$mirounga_leonina## construct and plot the map
SOmap_auto(ellie$lon, ellie$lat)
```The `SOmap_auto()`, `SOmap()`, and `SOmap2()` functions return the data used to make the map so that further customization can be made. Plotting or printing the returned object will cause the map to be displayed in the graphics device.
```{r automap2, fig.height = 5, fig.width = 5}
data("albatross", package = "adehabitatLT")
## convert the albatross data to a single matrix of lon, lat points
albatrack <- do.call(rbind, lapply(albatross, function(z) terra::project(rbind(as.matrix(z[, c("x", "y")]), NA), from = "+proj=utm +zone=42 +south +datum=WGS84", to = "EPSG:4326")))## construct the map and return it, but don't plot it
alb_map <- SOmap_auto(albatrack[, 1], albatrack[, 2])```
Modifying this map object is currently a rather experimental process (proceed at your own risk!) but, for example, if we wished to change the points to be blue rather than red:
```{r automap3, fig.height = 5, fig.width = 5}
alb_map$pcol <- "blue"
## plot it
alb_map
```We could also decide we want a reversed bathymetry color and cyan lines between the dots.
```{r automap4, fig.height = 5, fig.width = 5}
# change the line color
alb_map$lcol <- "cyan"
# reverse the bathymetry
alb_map$bathy_palette<-rev(alb_map$bathy_palette)## plot it
alb_map
```Objects from `sf`, `sp`, or `raster` can also be used, but note that they will be used for their extents only and will not automatically be plotted. But we can plot them easily with `SOplot`:
```{r automap-spatial, fig.height = 5, fig.width = 5}
## use the bundled fronts data as an example
mydata <- SOmap_data$fronts_orsi
SOmap_auto(mydata, target = "laea", centre_lon = 147)
SOplot(mydata, col = 2)```
## Easy projections
`SOmap` goes with the philosophy "we actually rather like ourselves, and care about our experience" and so there are some easy ways to work with projections, and just map it!.
```{r auto-setup}
set.seed(1)
amap <- SOmap_auto(input_points = FALSE, input_lines = FALSE)
amap
```To add data to this plot we can just do so.
```{r just-map-it}
amap
SOplot(SOmap_data$seaice_oct, lwd = 3, col = "blue", lty = 2)
````SOplot()` will add data by default, and can take spatial objects or even raw longitude and latitude values (we like you). When a plot is set up the *coordinate reference system* used is recorded so that we can use it again. The projection *currently in use* is always available by running `SOcrs()`.
```{r}
SOcrs()
```Many objects can be reprojected with `SOproj()`, including the map objects themselves.
```{r raster}
prj <- "+proj=laea +lat_0=-90 +lon_0=147 +datum=WGS84"
## reproject a raster
SOproj(ice, target = prj)## reproject a SOmap
SOproj(amap, target = prj)
```Note that we must assume raw input is "longitude/latitude", and the function will issue a warning.
---
Please note that the SOmap project is released with a [Contributor Code of Conduct](https://australianantarcticdivision.github.io/SOmap/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.