diff --git a/R/read.R b/R/read.R index 87aceb2d5..128d3fad7 100644 --- a/R/read.R +++ b/R/read.R @@ -233,8 +233,8 @@ process_cpl_read_ogr_stream = function(x, default_crs, num_features, fid_column_ df = suppressWarnings(nanoarrow::convert_array_stream(x, size = num_features)) df[is_geometry_column] = lapply(df[is_geometry_column], function(x) { - x = sf::st_as_sfc(wk::as_wkb(x)) - st_set_crs(x, crs) + attributes(x) <- NULL + sf::st_as_sfc(wk::new_wk_wkb(x, crs = crs)) }) # Prefer "geometry" as the geometry column name diff --git a/tests/testthat/test_sp.R b/tests/testthat/test_sp.R index 5ab4cfcf7..4ee8ee14b 100644 --- a/tests/testthat/test_sp.R +++ b/tests/testthat/test_sp.R @@ -104,6 +104,8 @@ test_that("Can convert `XY` objects to sp", { }) test_that("Can't convert `M` dimension to sp", { + # Segfaults using the stream interface + skip_if(default_st_read_use_stream()) skip_if_not_installed("sp") skip_if_not(sf_extSoftVersion()[["GDAL"]] >= "2.1.0") x <- read_sf(system.file("shape/storms_xyzm_feature.shp", package = "sf"), quiet = TRUE)