Closed edzer closed 3 years ago
Still the case. Please consider using sf::st_make_valid
on data with ellipsoidal coordinates.
> getTile(Up)
Error: Problem with `filter()` input `..1`.
ℹ Input `..1` is `lengths(.predicate(x, y, ...)) > 0`.
✖ Evaluation error: Found 4 features with invalid spherical geometry.
[13] Loop 0 is not valid: Edge 1 crosses edge 6
[18] Loop 0 is not valid: Edge 0 crosses edge 5
[446] Loop 0 is not valid: Edge 1 crosses edge 4
[451] Loop 0 is not valid: Edge 2 crosses edge 5.
Backtrace:
█
1. ├─MODIS::getTile(Up)
2. ├─MODIS::getTile(Up)
3. │ ├─MODIS::getTile(sf::st_as_sf(x), ...)
4. │ └─MODIS::getTile(sf::st_as_sf(x), ...)
5. │ ├─base::suppressMessages(sf::st_filter(sr, x))
6. │ │ └─base::withCallingHandlers(...)
7. │ ├─sf::st_filter(sr, x)
8. │ └─sf:::st_filter.sf(sr, x)
9. │ ├─dplyr::filter(x, lengths(.predicate(x, y, ...)) > 0)
10. │ ├─sf:::filter.sf(x, lengths(.predicate(x, y, ...)) > 0)
11. │ │ └─sf:::.re_sf(...)
12. │ │ └─base::stopifnot(...)
13. │ ├─base::NextMethod()
14. │ └─dplyr:::filter.data.frame(...)
15. │ └─dplyr:::filter_rows(.data, ...)
16. │ ├─base::withCallingHandlers(...)
17. │ └─mask$eval_all_filter(dots, env_filter)
18. ├─base::lengths(.predicate(x, y, ...))
19. ├─sf:::.predicate(x, y, ...)
20. ├─sf:::st_intersects.sf(x, y, ...)
21. │ └─sf:::st_geos_binop(...)
22. │ └─s2:::fn(x, y, s2::s2_options(model = s2_model, ...))
23. │ ├─s2:::cpp_s2_intersects_matrix(...)
24. │ ├─s2::as_s2_geography(x)
25. │ └─sf:::as_s2_geography.sf(x)
26. │ └─sf:::st_as_s2.sf(x, ..., oriented = oriented)
27. │ ├─sf::st_as_s2(st_geometry(x), ...)
28. │ └─sf:::st_as_s2.sfc(st_geometry(x), ...)
29. │ ├─s2::as_s2_geography(st_as_binary(x), ..., oriented = oriented)
30. │ └─s2:::as_s2_geography.WKB(st_as_binary(x), ..., oriented = oriented)
31. │ ├─s2:::new_s2_xptr(...)
32. │ └─s2:::s2_geography_from_wkb(x, oriented = oriented, check = check)
33. ├─base::stop(...)
34. └─(function (e) ...
Execution halted
You can test with s2 (1.0.5) from CRAN, and sf branch sf_1_0
from the github repo. Let me know if we can help.
FYI, MODIS was been removed from CRAN on June 28, 2021 because of these errors.
Users can install an archived version with remotes::install_version("MODIS", "1.2.3")
(though you'll run into the issues described above unless you also install an old version of sf).
install an old version of sf
... or use sf_use_s2(FALSE)
.
Dear Edzer, Thank you for insisting on this! I have been completely out from working on the MODIS package since quite a while now. I have tried to logon to my github but it asks me for a 2f auth which I had to reset now. After getting back the access I will have a look at this!!
Thanks again Matteo
Am Mi., 30. Juni 2021 um 18:41 Uhr schrieb Edzer Pebesma < @.***>:
... or use sf_use_s2(FALSE).
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/MatMatt/MODIS/issues/110#issuecomment-871563463, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA4F4GUQBHR7H4Q2UXQT6O3TVNCM3ANCNFSM43DMV6QA .
Great - let me know when you need help!
@edzer Thanks for the notification! I haven't been following the discussion in quite a while. From what I understand, would it be enough to examine any incoming geometry with sf::st_is_valid()
and, if required, then invoke sf::st_make_valid()
?
So to answer my own question, it seems like this approach is not viable. At least,
sf::sf_use_s2(TRUE)
data(meuse, package = "sp")
pts = sf::st_as_sf(meuse, coords = c("x", "y"), crs = 28992)
all(sf::st_is_valid(pts))
# TRUE
MODIS::getTile(pts[1, ])
using valid geometries only leads to the same error:
Error: Problem with `filter()` input `..1`.
ℹ Input `..1` is `lengths(.predicate(x, y, ...)) > 0`.
x Evaluation error: Found 4 features with invalid spherical geometry.
[13] Loop 0 is not valid: Edge 1 crosses edge 6
[18] Loop 0 is not valid: Edge 0 crosses edge 5
[446] Loop 0 is not valid: Edge 1 crosses edge 4
[451] Loop 0 is not valid: Edge 2 crosses edge 5.
Will start investigating with temporarily setting sf_use_s2(FALSE)
, in particular if this impacts the operability of the pkg.
Please see https://github.com/r-spatial/sf/issues/1649 - please consider commenting there if you get stuck! (@paleolimbot: another
✖ Loop 0 is not valid: Edge 1 crosses edge 6
)