Skip to content

Fix a failing test on geom_sf() #4915

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

Merged

Conversation

yutannihilation
Copy link
Member

It seems this currently errors because sf::st_crs(nc) returns NA (as nc is a sfg object, it doesn't have any CRS). This pull request just removes the line.

nc_tiny_coords <- data.frame(
  x = c(-81.473, -81.741, -81.67, -81.345, -81.266, -81.24, -81.473),
  y = c(36.234, 36.392, 36.59, 36.573, 36.437, 36.365, 36.234)
)

nc <- sf::st_linestring(
    sf::st_coordinates(sf::st_as_sf(nc_tiny_coords, coords = c("x", "y"), crs = 4326))
  )

nc2 <- sf::st_cast(
  sf::st_sfc(
    sf::st_multilinestring(lapply(
      1:(length(sf::st_coordinates(nc)[, 1]) - 1),
        function(x) rbind(
          as.numeric(sf::st_coordinates(nc)[x, 1:2]),
          as.numeric(sf::st_coordinates(nc)[x + 1, 1:2])
          )
      )
    ), sf::st_crs(nc)
  ), "LINESTRING"
)
#> Error in CPL_get_bbox(obj, 2): Not compatible with requested type: [type=character; target=double].

Created on 2022-07-23 by the reprex package (v2.0.1)

@yutannihilation yutannihilation merged commit 1dc2b35 into tidyverse:main Jul 26, 2022
@yutannihilation yutannihilation deleted the fix/fix-failing-geom_sf branch July 26, 2022 21:27
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

Successfully merging this pull request may close these issues.

2 participants