Skip to content

Commit

Permalink
merge.sf renames geometry column name to 'geometry'
Browse files Browse the repository at this point in the history
  • Loading branch information
faridcher authored Feb 5, 2024
1 parent 9073a52 commit 87b24ae
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions R/sf.R
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,13 @@ st_geometry.sfg = function(obj, ...) st_sfc(obj)
st_sf(x, sf_column_name = value)
else {
a = vapply(x, function(v) inherits(v, "sfc"), TRUE)
if (any(a)) {
w = which(a)
sf_col = attr(x, "sf_column")
if (! is.null(sf_col))
x[[ sf_col ]] = value
else {
if (length(w) > 1)
warning("overwriting first sfc column")
x[[ which(a)[1L] ]] = value
}
if (!is.null(sf_col))
x[[sf_col]] = value
else if (any(a)) {
w = which(a)
if (length(w) > 1)
warning("overwriting first sfc column")
x[[which(a)[1L]]] = value
} else
x$geometry = value
st_sf(x)
Expand Down Expand Up @@ -457,6 +454,7 @@ merge.sf = function(x, y, ...) {
class(ret) = setdiff(class(ret), "sf")
g = ret[[sf_column]] # may have NULL values in it
ret[[sf_column]] = NULL
attr(ret, "sf_column") <- sf_column
st_set_geometry(ret, st_sfc(g)) # FIXME: set agr
}

Expand Down

0 comments on commit 87b24ae

Please sign in to comment.