Skip to content

Commit

Permalink
feat: basemap function - fix #37
Browse files Browse the repository at this point in the history
  • Loading branch information
ahasverus committed Feb 12, 2024
1 parent f718bbb commit 777012c
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 10 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export(filter_by_ocean)
export(filter_by_polygon)
export(filter_by_species)
export(filter_by_year)
export(geom_basemap)
export(get_cpr_north_data)
export(get_cpr_south_data)
export(get_forcis_db)
Expand Down
27 changes: 27 additions & 0 deletions R/geom_basemap.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#' Add a World basemap to a ggplot object
#'
#' @description
#' This function creates a World base map that can be added to a ggplot object.
#' Spatial layers come from the Natural Earth project
#' (<https://www.naturalearthdata.com/>).
#'
#' @return A `ggplot` object.
#'
#' @export
#'
#' @examples
#' ## ADD EXAMPLE ----

geom_basemap <- function() {

list(
geom_sf(data = ne_oceans, fill = "#cdeafc", col = "#cdeafc",
linewidth = 0.10) +
geom_sf(data = ne_graticules, col = "#bae2fb",
linewidth = 0.10) +
geom_sf(data = ne_countries, fill = "#a6a6a6", col = "#b1b1b1",
linewidth = 0.10) +
geom_sf(data = ne_bbox, fill = NA, col = "#a6a6a6",
linewidth = 0.75)
)
}
11 changes: 1 addition & 10 deletions R/map_distribution.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,7 @@ map_distribution <- function(data, col = "red", ...) {

ggplot() +

### Basemap ----

geom_sf(data = ne_oceans, fill = "#cdeafc", col = "#cdeafc",
linewidth = 0.10) +
geom_sf(data = ne_graticules, col = "#bae2fb",
linewidth = 0.10) +
geom_sf(data = ne_countries, fill = "#a6a6a6", col = "#b1b1b1",
linewidth = 0.10) +
geom_sf(data = ne_bbox, fill = NA, col = "#a6a6a6",
linewidth = 0.75) +
geom_basemap() +


### Data ---
Expand Down
19 changes: 19 additions & 0 deletions man/geom_basemap.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 777012c

Please sign in to comment.