-
Notifications
You must be signed in to change notification settings - Fork 287
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
How to sp with sf #210
Comments
This is great! Will be very helpful to update workflows. Thanks for these references! |
See also here, calling for improvement. |
Here's a challenge (as discussed with @Nowosad, example from library(sp)
g = SpatialGrid(GridTopology(c(0, 0), c(1, 1), c(3, 3)))
p = as(g, "SpatialPolygons")
plot(p) over(p[5], p, returnList = TRUE, minDimension = 0)
#> $g5
#> [1] 5 2 4 6 8 1 3 7 9
over(p[5], p, returnList = TRUE, minDimension = 1)
#> $g5
#> [1] 5 2 4 6 8
over(p[5], p, returnList = TRUE, minDimension = 2)
#> $g5
#> [1] 5 |
If I find out the answer I'll happily document it. |
see #234 . |
Thanks for the link - hadn't read that and really useful things in there that can solve that specific use case, as commented in that issue. However, I don't think that thread addresses the question of how to "sp with sf" in that it does not provide a general replacement for the |
Here's a function that you could use in an s = st_as_sf(p)
> x = st_relate(s[5,], s)
> which_min_dim = function(x, n) {
switch(as.character(n),
"2" = which(substr(x, 1, 1) == "2"),
"1" = which(substr(x, 5, 5) == "1"),
"0" = which(substr(x, 5, 5) %in% c("0", "1")),
stop("wrong value for n")
)
}
> which_min_dim(x, 2)
[1] 5
> which_min_dim(x, 1)
[1] 2 4 5 6 8
> which_min_dim(x, 0)
[1] 1 2 3 4 5 6 7 8 9 |
Wow that's impressive! I've been thinking about this and was thinking of a helper function like |
This comment has nothing to do with sf, and you attached it to a
long-closed issue. If you want to ask about spdep, use issues there, not
here.
…On Mon, 4 May 2020 at 12:55, Arthur Katossky ***@***.***> wrote:
Does it makes sense to document in the same way the equivalence with
(relavant) functions from the spdep package? (I am especially thinking of
all the series of neighbor functions: tri2nb, knearneigh etc.)
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#210 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACNZ3BCAKM6IAE2ZZEMJQ2LRP2NLVANCNFSM4C7FYJCQ>
.
--
Roger Bivand
Falsensvei 32
N-5063 Bergen, Norway
Roger.Bivand@gmail.com
|
I kind-of realised that in the following minutes and suppressed the comment. (I am not sure I agree that it has nothing to do with |
It would be nice to have a list of
sp
,rgeos
andrgdal
commands with the corresponding command insf
, e.g.sp::disaggregate
->sf::st_cast
I started this in the sf wiki
The text was updated successfully, but these errors were encountered: