Skip to content

Commit

Permalink
Fix for new ggplot2 release
Browse files Browse the repository at this point in the history
  • Loading branch information
dieghernan committed Nov 7, 2022
1 parent 9a4df9e commit 18996f0
Show file tree
Hide file tree
Showing 90 changed files with 2,385 additions and 1,161 deletions.
26 changes: 21 additions & 5 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ references:
given-names: Gábor
email: [email protected]
year: '2022'
url: https://CRAN.R-project.org/package=cli
version: '>= 3.0.0'
- type: software
title: crayon
Expand All @@ -84,7 +85,7 @@ references:
given-names: Gábor
email: [email protected]
year: '2022'
url: https://github.com/r-lib/crayon#readme
url: https://CRAN.R-project.org/package=crayon
- type: software
title: data.table
abstract: 'data.table: Extension of `data.frame`'
Expand All @@ -97,6 +98,7 @@ references:
given-names: Arun
email: [email protected]
year: '2022'
url: https://CRAN.R-project.org/package=data.table
- type: software
title: dplyr
abstract: 'dplyr: A Grammar of Data Manipulation'
Expand All @@ -115,6 +117,7 @@ references:
given-names: Kirill
orcid: https://orcid.org/0000-0002-1416-3412
year: '2022'
url: https://CRAN.R-project.org/package=dplyr
version: '>= 1.0.0'
- type: software
title: ggplot2
Expand Down Expand Up @@ -149,6 +152,7 @@ references:
given-names: Dewey
orcid: https://orcid.org/0000-0002-9415-4582
year: '2022'
url: https://CRAN.R-project.org/package=ggplot2
version: '>= 3.1.0'
- type: software
title: magrittr
Expand All @@ -162,6 +166,7 @@ references:
given-names: Hadley
email: [email protected]
year: '2022'
url: https://CRAN.R-project.org/package=magrittr
- type: software
title: rlang
abstract: 'rlang: Functions for Base Types and Core R and ''Tidyverse'' Features'
Expand All @@ -174,6 +179,7 @@ references:
given-names: Hadley
email: [email protected]
year: '2022'
url: https://CRAN.R-project.org/package=rlang
- type: software
title: scales
abstract: 'scales: Scale Functions for Visualization'
Expand All @@ -185,6 +191,7 @@ references:
- family-names: Seidel
given-names: Dana
year: '2022'
url: https://CRAN.R-project.org/package=scales
- type: software
title: sf
abstract: 'sf: Simple Features for R'
Expand All @@ -195,6 +202,7 @@ references:
email: [email protected]
orcid: https://orcid.org/0000-0001-8049-7069
year: '2022'
url: https://CRAN.R-project.org/package=sf
version: '>= 1.0.0'
- type: software
title: terra
Expand All @@ -206,7 +214,7 @@ references:
email: [email protected]
orcid: https://orcid.org/0000-0001-5872-2872
year: '2022'
url: https://rspatial.org/terra/
url: https://CRAN.R-project.org/package=terra
version: '>= 1.5-12'
- type: software
title: tibble
Expand All @@ -220,6 +228,7 @@ references:
given-names: Hadley
email: [email protected]
year: '2022'
url: https://CRAN.R-project.org/package=tibble
version: '>= 3.0.0'
- type: software
title: tidyr
Expand All @@ -232,6 +241,7 @@ references:
- family-names: Girlich
given-names: Maximilian
year: '2022'
url: https://CRAN.R-project.org/package=tidyr
version: '>= 1.0.0'
- type: software
title: isoband
Expand All @@ -248,7 +258,7 @@ references:
email: [email protected]
orcid: https://orcid.org/0000-0002-5147-4711
year: '2022'
url: https://wilkelab.org/isoband/
url: https://CRAN.R-project.org/package=isoband
- type: software
title: knitr
abstract: 'knitr: A General-Purpose Package for Dynamic Report Generation in R'
Expand All @@ -259,7 +269,7 @@ references:
email: [email protected]
orcid: https://orcid.org/0000-0003-0645-5666
year: '2022'
url: https://yihui.org/knitr/
url: https://CRAN.R-project.org/package=knitr
- type: software
title: lifecycle
abstract: 'lifecycle: Manage the Life Cycle of your Package Functions'
Expand All @@ -273,6 +283,7 @@ references:
email: [email protected]
orcid: https://orcid.org/0000-0003-4757-117X
year: '2022'
url: https://CRAN.R-project.org/package=lifecycle
- type: software
title: maptiles
abstract: 'maptiles: Download and Display Map Tiles'
Expand All @@ -283,7 +294,7 @@ references:
email: [email protected]
orcid: https://orcid.org/0000-0002-1932-3323
year: '2022'
url: https://github.com/riatelab/maptiles/
url: https://CRAN.R-project.org/package=maptiles
- type: software
title: rmarkdown
abstract: 'rmarkdown: Dynamic Documents for R'
Expand Down Expand Up @@ -322,6 +333,7 @@ references:
email: [email protected]
orcid: https://orcid.org/0000-0003-3925-190X
year: '2022'
url: https://CRAN.R-project.org/package=rmarkdown
- type: software
title: s2
abstract: 's2: Spherical Geometry Operators Using the S2 Geometry Library'
Expand All @@ -339,6 +351,7 @@ references:
given-names: Ege
email: [email protected]
year: '2022'
url: https://CRAN.R-project.org/package=s2
- type: software
title: testthat
abstract: 'testthat: Unit Testing for R'
Expand All @@ -348,6 +361,7 @@ references:
given-names: Hadley
email: [email protected]
year: '2022'
url: https://CRAN.R-project.org/package=testthat
version: '>= 3.0.0'
- type: software
title: tidyverse
Expand All @@ -358,6 +372,7 @@ references:
given-names: Hadley
email: [email protected]
year: '2022'
url: https://CRAN.R-project.org/package=tidyverse
- type: software
title: vdiffr
abstract: 'vdiffr: Visual Regression Testing and Graphical Diffing'
Expand All @@ -380,3 +395,4 @@ references:
given-names: Vaudor
email: [email protected]
year: '2022'
url: https://CRAN.R-project.org/package=vdiffr
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ importFrom(dplyr,slice_sample)
importFrom(dplyr,slice_tail)
importFrom(dplyr,transmute)
importFrom(ggplot2,aes)
importFrom(ggplot2,after_stat)
importFrom(ggplot2,alpha)
importFrom(ggplot2,autoplot)
importFrom(ggplot2,fortify)
Expand Down
4 changes: 2 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
`fortify.SpatRaster()`, `fortify.SpatVector()`.
- Three additional palettes are included on `hypso.colors()`: `"artic"`,
`"meyers"` and `"nordisk-familjebok"`.
- Added colour scales to all palettes: `scale_colour_*`.
- Added colour scales to all palettes: `scale_colour_*`.
- Remove use of `ggplot2::aes_string()`.

# tidyterra 0.3.0

Expand Down
1 change: 0 additions & 1 deletion R/drop_na.Spat.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
#' drop_na(iso2) %>%
#' plot(col = "red")
drop_na.SpatVector <- function(data, ...) {

# Use sf method
sf_obj <- sf::st_as_sf(data)
dropped <- tidyr::drop_na(sf_obj, ...)
Expand Down
1 change: 0 additions & 1 deletion R/filter.Spat.R
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ filter.SpatRaster <- function(.data, ..., .preserve = FALSE,
#' @export
#' @rdname filter.Spat
filter.SpatVector <- function(.data, ..., .preserve = FALSE) {

# Use sf method
sf_obj <- sf::st_as_sf(.data)
filtered <- dplyr::filter(sf_obj, ..., .preserve = .preserve)
Expand Down
3 changes: 0 additions & 3 deletions R/geom_spat_contour.R
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ geom_spatraster_contour <- function(mapping = NULL, data,
na.rm = TRUE,
show.legend = NA,
inherit.aes = TRUE) {

# Is a suggestion so far
# nocov start
if (!requireNamespace("isoband", quietly = TRUE)) {
Expand Down Expand Up @@ -294,8 +293,6 @@ StatTerraSpatRasterContour <- ggplot2::ggproto(
compute_group = function(data, scales, z.range, bins = NULL, binwidth = NULL,
breaks = NULL, na.rm = FALSE, coord,
coord_crs = NA) {


# Extract raster from group
rast <- data$spatraster[[1]]

Expand Down
3 changes: 0 additions & 3 deletions R/geom_spat_contour_fill.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ geom_spatraster_contour_filled <- function(mapping = NULL, data,
na.rm = TRUE,
show.legend = NA,
inherit.aes = TRUE) {

# Is a suggestion so far

# nocov start
Expand Down Expand Up @@ -171,8 +170,6 @@ StatTerraSpatRasterContourFill <- ggplot2::ggproto(
compute_group = function(data, scales, z.range, bins = NULL, binwidth = NULL,
breaks = NULL, na.rm = FALSE, coord,
coord_crs = NA) {


# Extract raster from group
rast <- data$spatraster[[1]]

Expand Down
19 changes: 11 additions & 8 deletions R/geom_spatraster.R
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,6 @@ StatTerraSpatRaster <- ggplot2::ggproto(
},
compute_group = function(data, scales, coord, params,
coord_crs = NA) {

# Extract raster from group
rast <- data$spatraster[[1]]

Expand Down Expand Up @@ -303,7 +302,6 @@ remove_columns <- function(x, rem) {
# Reproject a SpatRaster with params
reproject_raster_on_stat <- function(raster,
coords_crs = NA) {

# Check if need to reproject
crs_terra <- pull_crs(raster)

Expand Down Expand Up @@ -429,13 +427,16 @@ prepare_aes_spatraster <- function(mapping = aes(),
# Prepare aes for StatTerraSpatRaster
mapinit <- cleanup_aesthetics(mapping, "group")

spatraster <- NULL
lyr <- NULL

mapinit <- override_aesthetics(
mapinit,
ggplot2::aes_string(
spatraster = "spatraster",
ggplot2::aes(
spatraster = spatraster,
# For faceting
lyr = "lyr",
group = "lyr"
lyr = lyr,
group = lyr
)
)

Expand All @@ -462,10 +463,11 @@ prepare_aes_spatraster <- function(mapping = aes(),
is_layer <- fill_from_aes %in% raster_names


value <- NULL
# If not provided add after_stat
if (fill_not_provided) {
map_not_prov <- override_aesthetics(
mapinit, ggplot2::aes_string(fill = "ggplot2::after_stat(value)")
mapinit, ggplot2::aes(fill = after_stat(value))
)

result_obj$map <- map_not_prov
Expand All @@ -474,8 +476,9 @@ prepare_aes_spatraster <- function(mapping = aes(),

# If it is a layer need to override the fill value and keep the namelayer
if (is_layer) {
value <- NULL
map_layer <- override_aesthetics(
ggplot2::aes_string(fill = "ggplot2::after_stat(value)"),
ggplot2::aes(fill = after_stat(value)),
mapinit
)

Expand Down
7 changes: 3 additions & 4 deletions R/geom_spatraster_rgb.R
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,11 @@ geom_spatraster_rgb <- function(mapping = aes(),
}

# 1. Work with aes ----
spatraster <- NULL
mapping <- override_aesthetics(
mapping,
ggplot2::aes_string(
spatraster = "spatraster"
ggplot2::aes(
spatraster = spatraster
)
)

Expand Down Expand Up @@ -189,7 +190,6 @@ StatTerraSpatRasterRGB <- ggplot2::ggproto(
required_aes = "spatraster",
extra_params = c("maxcell", "max_col_value", "na.rm"),
compute_layer = function(self, data, params, layout) {

# add coord to the params, so it can be forwarded to compute_group()
params$coord_crs <- pull_crs(layout$coord_params$crs)

Expand Down Expand Up @@ -278,7 +278,6 @@ GeomTerraSpatRasterRGB <- ggplot2::ggproto(
# Create a table with the hex color of each row (hexcol)
# On any NA then hexcol is returned as NA
make_hexcol <- function(data, max_col_value = 255) {

# Clamp values
data[data > max_col_value] <- max_col_value
data[data < 0] <- 0
Expand Down
1 change: 0 additions & 1 deletion R/geom_spatvector.R
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ stat_spatvector <- function(mapping = NULL,
show.legend = NA,
inherit.aes = TRUE,
...) {

# nocov start
ggplot2::stat_sf(
mapping = mapping,
Expand Down
1 change: 0 additions & 1 deletion R/is_regular_grid.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
#' is_regular_grid(p_jitter, digits = 4)
#'
is_regular_grid <- function(xy, digits = 6) {

# From https://github.com/rspatial/terra/blob/master/R/rast.R

# Need to work out with tibbles
Expand Down
2 changes: 0 additions & 2 deletions R/mutate.Spat.R
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ mutate.SpatRaster <- function(.data, ...) {
#' @export
#' @rdname mutate.Spat
mutate.SpatVector <- function(.data, ...) {

# Use sf method
sf_obj <- sf::st_as_sf(.data)
mutated <- dplyr::mutate(sf_obj, ...)
Expand Down Expand Up @@ -165,7 +164,6 @@ transmute.SpatRaster <- function(.data, ...) {
#' @export
#' @rdname mutate.Spat
transmute.SpatVector <- function(.data, ...) {

# Use sf method
sf_obj <- sf::st_as_sf(.data)
transm <- dplyr::transmute(sf_obj, ...)
Expand Down
1 change: 0 additions & 1 deletion R/pull_crs.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
#'
#' cat(fromsf1)
pull_crs <- function(.data, ...) {

# Spat* objects handled by crs
if (any(
inherits(.data, "SpatRaster"),
Expand Down
2 changes: 0 additions & 2 deletions R/relocate.Spat.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
#' relocate(cyl_tile_1, .after = last_col())
#'
relocate.SpatRaster <- function(.data, ..., .before = NULL, .after = NULL) {

# With template
df <- .data[1]

Expand All @@ -78,7 +77,6 @@ relocate.SpatRaster <- function(.data, ..., .before = NULL, .after = NULL) {
#' @rdname relocate.Spat
#' @export
relocate.SpatVector <- function(.data, ..., .before = NULL, .after = NULL) {

# Use sf method
sf_obj <- sf::st_as_sf(.data)
relocated <- dplyr::relocate(sf_obj, ...,
Expand Down
Loading

0 comments on commit 18996f0

Please sign in to comment.