Skip to content

Commit 4187a8c

Browse files
committed
set z_range and m_range in st_as_sf.data.frame()
fixes geoarrow/geoarrow-r#75
1 parent 0797535 commit 4187a8c

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# version 1.0-23
2+
3+
* `st_as_sf.data.frame()` sets `z_range` and `m_range`; https://github.com/geoarrow/geoarrow-r/issues/75
4+
15
# version 1.0-22
26

37
* `st_combine()` on `POINT` geometries ignores empty points; #2551

R/sf.R

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,20 +60,24 @@ st_as_sf.data.frame = function(x, ..., agr = NA_agr_, coords, wkt,
6060
do.call(c, apply(cc, 1, fn))
6161
} else { # points:
6262
structure(points_rcpp(cc, dim),
63-
n_empty = 0L, precision = 0, crs = NA_crs_,
64-
bbox = structure(
65-
c(xmin = min(cc[,1], na.rm = TRUE),
66-
ymin = min(cc[,2], na.rm = TRUE),
67-
xmax = max(cc[,1], na.rm = TRUE),
68-
ymax = max(cc[,2], na.rm = TRUE)), class = "bbox"),
69-
class = c("sfc_POINT", "sfc" ), names = NULL)
63+
n_empty = 0L, precision = 0, crs = NA_crs_,
64+
bbox = structure(
65+
c(xmin = min(cc[,1], na.rm = TRUE),
66+
ymin = min(cc[,2], na.rm = TRUE),
67+
xmax = max(cc[,1], na.rm = TRUE),
68+
ymax = max(cc[,2], na.rm = TRUE)), class = "bbox"),
69+
class = c("sfc_POINT", "sfc" ), names = NULL)
7070
}
7171

7272
if (remove) {
7373
if (is.character(coords))
7474
coords = match(coords, names(x))
7575
x = x[-coords]
7676
}
77+
if (grepl("Z", dim))
78+
attr(x[[sf_column_name]], "z_range") = compute_z_range(x[[sf_column_name]])
79+
if (grepl("M", dim))
80+
attr(x[[sf_column_name]], "m_range") = compute_m_range(x[[sf_column_name]])
7781

7882
}
7983
st_sf(x, ..., agr = agr, sf_column_name = sf_column_name)

0 commit comments

Comments
 (0)