Skip to content

st_make_valid error with lat/lon CRS and defined geos_method argument #2315

@sean-rohan-NOAA

Description

@sean-rohan-NOAA

Describe the bug
st_make_valid() throws the following error when the CRS for x is lat/lon and the user specifies a geos_method argument:

Error in st_make_valid.sfc(st_geometry(x), ...) :
missing(geos_method) is not TRUE

The issue happens with sf 1.0-15 and 1.0-16 but not 1.0-12. I'm wondering if it's related to e0dd1de

To Reproduce

library(sf)

# WGS84 
test_wgs84 <- data.frame(x = 1, y = 1, z = "hi") |> 
  st_as_sf(coords = c("x", "y"), crs = "WGS84")

# Works
st_make_valid(test_wgs84)

# Doesn't work
st_make_valid(test_wgs84, geos_method = "valid_structure")
st_make_valid(test_wgs84, geos_method = "valid_linework")

# NAD83
test_nad83 <- data.frame(x = 1, y = 1, z = "hi") |> 
  st_as_sf(coords = c("x", "y"), crs = "EPSG:4269")

# Works
st_make_valid(test_nad83)

# Doesn't work
st_make_valid(test_nad83, geos_method = "valid_structure")
st_make_valid(test_nad83, geos_method = "valid_linework")


# Alaska Albers Equal Area
test_aea <- data.frame(x = 1, y = 1, z = "hi") |> 
  st_as_sf(coords = c("x", "y"), crs = "EPSG:3338")

# All work
st_make_valid(test_aea)
st_make_valid(test_aea, geos_method = "valid_structure")
st_make_valid(test_aea, geos_method = "valid_linework")

If reporting a change from previous versions

Additional context

R version 4.3.2 (2023-10-31 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19045)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.utf8 LC_CTYPE=English_United States.utf8 LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C LC_TIME=English_United States.utf8

time zone: America/Los_Angeles
tzcode source: internal

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] sf_1.0-16

loaded via a namespace (and not attached):
[1] s2_1.1.6 utf8_1.2.4 R6_2.5.1 tidyselect_1.2.0 e1071_1.7-14 magrittr_2.0.3
[7] glue_1.7.0 tibble_3.2.1 KernSmooth_2.23-22 pkgconfig_2.0.3 generics_0.1.3 dplyr_1.1.4
[13] wk_0.9.1 lifecycle_1.0.4 classInt_0.4-10 cli_3.6.2 fansi_1.0.6 grid_4.3.2
[19] vctrs_0.6.5 DBI_1.2.1 proxy_0.4-27 class_7.3-22 compiler_4.3.2 rstudioapi_0.15.0
[25] tools_4.3.2 pillar_1.9.0 Rcpp_1.0.12 rlang_1.1.3 units_0.8-5 `

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions