Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vctrs doesn't like geos_geometry columns #1945

Open
guslipkin opened this issue Jul 2, 2024 · 0 comments
Open

vctrs doesn't like geos_geometry columns #1945

guslipkin opened this issue Jul 2, 2024 · 0 comments

Comments

@guslipkin
Copy link

I was testing {geos} and came across the below error that said to report it. The issue is with the geometry column which is a geos_geometry polygon.

I know you usually wouldn't want to join this way on a geometry column.

.drawing_feature_to_geos <- function(feature) {
  feature |>
    unlist(recursive = FALSE) |>
    purrr::map(\(x) {
      x <-
        x |>
        unlist() |>
        `names<-`(c('x', 'y'))
      return(x)
    }) |>
    dplyr::bind_rows() |>
    (\(m) {
      geos::geos_make_polygon(m$x, m$y, crs = 4326)
    })() |>
    tibble::tibble() |>
    `colnames<-`('geometry')
}

geos1 <-
  list(list(
    list(-239.654911, -55.972427),
    list(-54.364094, -52.659505),
    list(-229.046736, -83.2853),
    list(-239.654911, -55.972427)
  )) |>
  .drawing_feature_to_geos() |>
  dplyr::mutate('id' = 1)

 geos1 |>
   dplyr::anti_join(
     y = {
       list(list(
         list(239.654911, 55.972427),
         list(54.364094, 52.659505),
         list(229.046736, 83.2853),
         list(239.654911, 55.972427)
       )) |>
         .drawing_feature_to_geos()
     }
   ) |>
   dplyr::mutate('id' = 1)
#> Joining with `by = join_by(geometry)`
#> Error in `vctrs::vec_locate_matches()`:
#> ! Unsupported vctrs type `list`.
#> ℹ In file 'type-info.c' at line 189.
#> ℹ This is an internal error that was detected in the vctrs package.
#>   Please report it at <https://github.com/r-lib/vctrs/issues> with a reprex (<https://tidyverse.org/help/>) and the full backtrace.

Created on 2024-07-02 with reprex v2.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant