Skip to content

Commit

Permalink
1.3.0 version submitted to CRAN
Browse files Browse the repository at this point in the history
  • Loading branch information
MikkoVihtakari committed Sep 20, 2022
1 parent 66d666f commit 17ecc32
Show file tree
Hide file tree
Showing 14 changed files with 176 additions and 35 deletions.
7 changes: 6 additions & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
[.]DS_Store$
\\.DS_Store$
^.*\.DS_Store$
^\.DS_Store$
"(^|/)\\.DS_Store$"
^.*\.Rproj$
^\.Rproj\.user$
^README\.md$
Expand All @@ -12,4 +17,4 @@
^NEWS\.md$
^ggOceanMapsData
^vignettes$
^\.DS_Store$

6 changes: 4 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: ggOceanMaps
Type: Package
Title: Plot Data on Oceanographic Maps using 'ggplot2'
Version: 1.2.17
Date: 2022-09-19
Version: 1.3.0
Date: 2022-09-20
Authors@R: c(person("Mikko", "Vihtakari", email = "mikko.vihtakari@hi.no",
role = c("aut", "cre"),
comment = c(affiliation = "Institute of Marine Research",
Expand Down Expand Up @@ -32,3 +32,5 @@ Additional_repositories: https://mikkovihtakari.github.io/drat
License: GPL-3
Encoding: UTF-8
RoxygenNote: 7.2.1
LazyData: true

44 changes: 44 additions & 0 deletions R/datasets-docs.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#' @title Major fisheries areas (hovedomraade) of Norway
#' @docType data
#' @keywords datasets shapefiles fishery
#' @family datasets
#' @name fdir_main_areas
#' @format \code{\link[sf:st_sf]{sf object}} in decimal degrees (EPSG:4326) containing major fishing zones defined by the Norwegian Directorate of Fisheries. Contains also Northwest Atlantic Fisheries Organization's divisions where Norwegian vessels tend to fish.
#' @source \href{https://open-data-fiskeridirektoratet-fiskeridir.hub.arcgis.com/}{Norwegian Directorate of Fisheries} and \href{https://www.nafo.int/About-us/Maps}{Northwest Atlantic Fisheries Organization}
#' @import sf
#' @examples
#' \donttest{
#' basemap(fdir_main_areas) +
#' annotation_spatial(fdir_main_areas, fill = NA)
#' }
"fdir_main_areas"

#' @title Norwegian sub-areas (lokasjon) for commercial fishing
#' @docType data
#' @keywords datasets shapefiles fishery
#' @family datasets
#' @name fdir_sub_areas
#' @format \code{\link[sf:st_sf]{sf object}} in decimal degrees (EPSG:4326) containing major fishing zones defined by the Norwegian Directorate of Fisheries.
#' @source \href{https://open-data-fiskeridirektoratet-fiskeridir.hub.arcgis.com/}{Norwegian Directorate of Fisheries}
#' @import sf
#' @examples
#' \donttest{
#' basemap(fdir_sub_areas) +
#' annotation_spatial(fdir_sub_areas, fill = NA)
#' }
"fdir_sub_areas"

#' @title ICES Advisory Areas
#' @docType data
#' @keywords datasets shapefiles fishery
#' @family datasets
#' @name ices_areas
#' @format \code{\link[sf:st_sf]{sf object}} in decimal degrees (EPSG:4326) containing ICES Advisory Areas.
#' @source \href{https://www.ices.dk/}{International Council for the Exploration of the Sea}
#' @import sf
#' @examples
#' \donttest{
#' basemap(ices_areas) +
#' annotation_spatial(ices_areas, fill = NA)
#' }
"ices_areas"
2 changes: 1 addition & 1 deletion R/reorder_layers.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#' @author Mikko Vihtakari
#' @examples
#' \donttest{
#' data("ices_areas", package = "ggOceanMapsData")
#' data("ices_areas")
#' p <- basemap(c(-20, 15, 50, 70)) +
#' annotation_spatial(ices_areas, aes(fill = Area_Full), show.legend = FALSE)
#'
Expand Down
11 changes: 11 additions & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,17 @@ reference:
- LS
- FS

- reference:
- title: Datasets
desc: >
The package contains ICES and Norwegian Directorat of Fisheries areas as sf
objects. These shapefiles are used in examples and included here for
convinience because they are regurlarly needed by the package author.
contents:
- ices_areas
- fdir_main_areas
- fdir_sub_areas

- title: Internal basemap functions
desc: >
Internal functions dealing with data and graphics for basemap. These
Expand Down
Binary file added data/fdir_areas.rda
Binary file not shown.
Binary file added data/ices_areas.rda
Binary file not shown.
20 changes: 0 additions & 20 deletions ggOceanMaps.Rproj

This file was deleted.

33 changes: 33 additions & 0 deletions man/fdir_main_areas.Rd

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

33 changes: 33 additions & 0 deletions man/fdir_sub_areas.Rd

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

33 changes: 33 additions & 0 deletions man/ices_areas.Rd

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

2 changes: 1 addition & 1 deletion man/reorder_layers.Rd

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

2 changes: 1 addition & 1 deletion vignettes/detailed-maps.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ basemap(shapefiles = "BarentsSea", bathymetry = TRUE)
basemap(shapefiles = "IBCAO", bathymetry = TRUE)
```

## The Northern hemisphere (GEBCO)
### The Northern hemisphere (GEBCO)

The entire GEBCO grid from the North Pole to 10&deg;N vectorized and packed into a >60 Mb R data file. When opened, the data take >3 Gb. This is a clumsy approach and plotting maps using this option can take a long time (up to 10 minutes on a test machine) and will make your computer to beg for mercy. Use this as the last resort and do not blame the package author that you were not warned ;)

Expand Down
18 changes: 9 additions & 9 deletions vignettes/ggOceanMaps.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ The stereographic maps can be rotated to point towards north using the `rotate`
basemap(limits = c(-160, -80, 60, 85), rotate = TRUE)
```

A word of warning, however: the rotation involves reprojecting all shapefiles in their entirety and is memory consuming especially for large bathymetry shapes. Make sure to limit your map correctly before you add bathymetry. The rotation is still experimental and does not work for `limit`s defined using projected coordinates or `data`. This functionality is likely to contain a whole lot of bugs. Rotation does not currently work within the `transform_coord()` function. Use the `ggspatial::geom_spatial_*` functions when adding data to rotated maps.
A word of warning, however: the rotation involves reprojecting all shapefiles in their entirety and is memory consuming especially for large bathymetry shapes. Rotation does not currently work within the `transform_coord()` function. Use the `ggspatial::geom_spatial_*` functions when adding data to rotated maps.

## Quick map

Expand Down Expand Up @@ -313,22 +313,22 @@ Sometimes there is a need to move land, glacier, and grid layers on top of spati
The Norwegian fishing regions are included as an example dataset in the **ggOceanMaps** package. You can download these data and use the `rgdal::readOGR` function to read the shapefile if you wish to follow the example fully.

```{r}
data(fishingAreasNor, package = "ggOceanMapsData")
data(fdir_areas)
basemap(fishingAreasNor) +
annotation_spatial(fishingAreasNor, fill = NA) +
basemap(fdir_main_areas) +
annotation_spatial(fdir_main_areas, fill = NA) +
coord_sf(expand = FALSE) # required to keep the limits
```

The initial plot draws the polygons. Note how we had to add `coord_sf(expand = FALSE)` because `layer_spatial` and `annotation_spatial` functions from the ggspatial package seem to modify `coord_sf` when added to the plot. The `basemap` function uses `expand = FALSE` (run the script without the addition and see the difference). Note also how the polygon boundaries are partly on land. We want to eventually hide them under land. We also add region labels and color the polygons based on their area to demonstrate the capabilities of ggplot, ggspatial and ggOceanMaps:

```{r}
labels <- suppressWarnings(sf::st_centroid(fishingAreasNor))
fishingAreasNor$area <- as.numeric(sf::st_area(fishingAreasNor))/1e9 # calculate area in 1000 km2
labels <- suppressWarnings(sf::st_centroid(fdir_main_areas))
fdir_main_areas$area <- as.numeric(sf::st_area(fdir_main_areas))/1e9 # calculate area in 1000 km2
p <- basemap(fishingAreasNor) +
geom_sf(data = fishingAreasNor, aes(fill = area)) +
geom_sf_text(data = labels, aes(label = FID), size = FS(8), fontface = 2) +
p <- basemap(fdir_main_areas) +
geom_sf(data = fdir_main_areas, aes(fill = area)) +
geom_sf_text(data = labels, aes(label = main_area), size = FS(8), fontface = 2) +
scale_fill_distiller(name = "Area\n(1000 km2)",
palette = "Spectral", na.value = "white",
limits = c(0, 500), oob = scales::squish)
Expand Down

0 comments on commit 17ecc32

Please sign in to comment.