Skip to content

Commit

Permalink
closes #2204
Browse files Browse the repository at this point in the history
  • Loading branch information
edzer committed Aug 6, 2023
1 parent 7ae54ed commit 9a7f212
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# version 1.0-15

* `distinct.sf` is type-safe for `sf` objects with zero rows; #2204

* `summarise.sf` raises an error if `.by` is given but no `across()` on the geometry; #2207

* `st_write()` matches fields on name first, than on position; this matters for formats that have pre-defined names, such as GPX; #2202
Expand Down
2 changes: 2 additions & 0 deletions R/tidyverse.R
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,8 @@ distinct.sf <- function(.data, ..., .keep_all = FALSE) {
sf_column = attr(.data, "sf_column")
geom = st_geometry(.data)
eq = sapply(st_equals(.data), head, n = 1)
if (is.list(eq) && length(eq) == 0) # empty list: geometry was empty set
eq = integer(0)
empties = which(lengths(eq) == 0)
eq[ empties ] = empties[1] # first empty record
.data[[ sf_column ]] = unlist(eq)
Expand Down

0 comments on commit 9a7f212

Please sign in to comment.