Skip to content

Commit

Permalink
plot.sf accepts duplicate in breaks
Browse files Browse the repository at this point in the history
  • Loading branch information
edzer committed Jan 10, 2025
1 parent cf894c3 commit cb2c3bf
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
12 changes: 11 additions & 1 deletion R/plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ kw_dflt = function(x, key.pos) {
lcm(1.8 * font_scale)
}

# like cut.default, but only return integers, and allow for duplicate breaks:
sf_cut = function(values, breaks, include.lowest = TRUE) {
i = findInterval(values, breaks, left.open = TRUE)
if (include.lowest)
i[values == breaks[1]] = 1
i[i == 0 | i == length(breaks)] = NA
i
}

#' plot sf object
#'
Expand Down Expand Up @@ -231,8 +239,10 @@ plot.sf <- function(x, y, ..., main, pal = NULL, nbreaks = 10, breaks = "pretty"
rep(NA_integer_, length(values))
else if (!breaks_numeric && diff(range(values, na.rm = TRUE)) == 0)
ifelse(is.na(values), NA_integer_, 1L)
else
else if (inherits(values, c("POSIXt", "Date")))
cut(values, breaks, include.lowest = TRUE)
else
sf_cut(values, breaks, include.lowest = TRUE)
colors = if (is.function(pal))
pal(nbreaks)
else
Expand Down
4 changes: 2 additions & 2 deletions inst/docker/gdal/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ RUN cd proj* \

# GDAL:
ENV GDAL_VERSION 3.10.1
ENV GDAL_VERSION_NAME 3.10.1rc1
ENV GDAL_VERSION_NAME 3.10.1rc2
#https://download.osgeo.org/gdal/3.9.0/gdal-3.9.0beta1.tar.gz
#https://download.osgeo.org/gdal/3.10.0/gdal-3.10.0beta1.tar.gz

Expand Down Expand Up @@ -135,4 +135,4 @@ RUN R CMD check --no-build-vignettes --no-manual --as-cran lwgeom_*.tar.gz
#
RUN Rscript -e 'options(timeout=1200); install.packages("starsdata", repos="http://cran.uni-muenster.de/pebesma/")'
#
#RUN _R_CHECK_FORCE_SUGGESTS_=false R CMD check --no-build-vignettes --no-manual --as-cran stars_*.tar.gz
RUN _R_CHECK_FORCE_SUGGESTS_=false R CMD check --no-build-vignettes --no-manual --as-cran stars_*.tar.gz
2 changes: 1 addition & 1 deletion man/sf-package.Rd

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

0 comments on commit cb2c3bf

Please sign in to comment.