Skip to content

Commit cb2c3bf

Browse files
committed
plot.sf accepts duplicate in breaks
needed for r-spatial/stars#728
1 parent cf894c3 commit cb2c3bf

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

R/plot.R

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ kw_dflt = function(x, key.pos) {
1616
lcm(1.8 * font_scale)
1717
}
1818

19+
# like cut.default, but only return integers, and allow for duplicate breaks:
20+
sf_cut = function(values, breaks, include.lowest = TRUE) {
21+
i = findInterval(values, breaks, left.open = TRUE)
22+
if (include.lowest)
23+
i[values == breaks[1]] = 1
24+
i[i == 0 | i == length(breaks)] = NA
25+
i
26+
}
1927

2028
#' plot sf object
2129
#'
@@ -231,8 +239,10 @@ plot.sf <- function(x, y, ..., main, pal = NULL, nbreaks = 10, breaks = "pretty"
231239
rep(NA_integer_, length(values))
232240
else if (!breaks_numeric && diff(range(values, na.rm = TRUE)) == 0)
233241
ifelse(is.na(values), NA_integer_, 1L)
234-
else
242+
else if (inherits(values, c("POSIXt", "Date")))
235243
cut(values, breaks, include.lowest = TRUE)
244+
else
245+
sf_cut(values, breaks, include.lowest = TRUE)
236246
colors = if (is.function(pal))
237247
pal(nbreaks)
238248
else

inst/docker/gdal/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ RUN cd proj* \
101101

102102
# GDAL:
103103
ENV GDAL_VERSION 3.10.1
104-
ENV GDAL_VERSION_NAME 3.10.1rc1
104+
ENV GDAL_VERSION_NAME 3.10.1rc2
105105
#https://download.osgeo.org/gdal/3.9.0/gdal-3.9.0beta1.tar.gz
106106
#https://download.osgeo.org/gdal/3.10.0/gdal-3.10.0beta1.tar.gz
107107

@@ -135,4 +135,4 @@ RUN R CMD check --no-build-vignettes --no-manual --as-cran lwgeom_*.tar.gz
135135
#
136136
RUN Rscript -e 'options(timeout=1200); install.packages("starsdata", repos="http://cran.uni-muenster.de/pebesma/")'
137137
#
138-
#RUN _R_CHECK_FORCE_SUGGESTS_=false R CMD check --no-build-vignettes --no-manual --as-cran stars_*.tar.gz
138+
RUN _R_CHECK_FORCE_SUGGESTS_=false R CMD check --no-build-vignettes --no-manual --as-cran stars_*.tar.gz

man/sf-package.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)