tests/testthat/test-sf.R

test_that("st_crop and st_intersection", {
  m <- mt_read(mt_example())
  poly <- sf::st_polygon(list(cbind(
    c(-73.96285, -73.83646, -73.77327, -73.86531, -73.96285),
    c(42.75987, 42.82641, 42.71446, 42.68517, 42.75987)
  ))) |>
    sf::st_sfc(crs = sf::st_crs(m))
  suppressWarnings(expect_identical(sf::st_intersection(m, poly) |> mt_track_id() |> unique() |> as.character(), c("F1", "F2", "F3", "M1", "M2", "M3")))
  suppressWarnings(expect_identical(sf::st_crop(m, poly) |> mt_track_id() |> unique() |> as.character(), c("F1", "F2", "F3", "M1", "M2", "M3", "M4")))
})

Try the move2 package in your browser

Any scripts or data that you put into this service are public.

move2 documentation built on April 4, 2025, 12:24 a.m.