Skip to content

Commit

Permalink
fixes #2293
Browse files Browse the repository at this point in the history
  • Loading branch information
edzer committed Dec 14, 2023
1 parent 70ecb7c commit 157273d
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions R/sf.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ st_as_sf.data.frame = function(x, ..., agr = NA_agr_, coords, wkt,
if (na.fail && anyNA(cc))
stop("missing values in coordinates not allowed")
# classdim = getClassDim(rep(0, length(coords)), length(coords), dim, "POINT")
x$geometry = structure( points_rcpp(as.matrix(cc), dim),
if (is.null(sf_column_name))
sf_column_name = "geometry"
x[[sf_column_name]] = structure( points_rcpp(as.matrix(cc), dim),
n_empty = 0L, precision = 0, crs = NA_crs_,
bbox = structure(
c(xmin = min(cc[[1]], na.rm = TRUE),
Expand All @@ -57,11 +59,12 @@ st_as_sf.data.frame = function(x, ..., agr = NA_agr_, coords, wkt,
ymax = max(cc[[2]], na.rm = TRUE)), class = "bbox"),
class = c("sfc_POINT", "sfc" ), names = NULL)

if (is.character(coords))
coords = match(coords, names(x))

if (remove)
if (remove) {
if (is.character(coords))
coords = match(coords, names(x))
x = x[-coords]
}

}
st_sf(x, ..., agr = agr, sf_column_name = sf_column_name)
}
Expand Down

0 comments on commit 157273d

Please sign in to comment.