sfnetwork to linnet #207
mkvasnicka
started this conversation in
Ideas
Replies: 2 comments 4 replies
-
Hi @mkvasnicka and thanks for your message. Just to be clear, the problem is that something like # packages
library(spatstat)
library(sf)
library(sfnetworks)
# toy network
toy_segment = st_sfc(st_linestring(
rbind(c(0, 0), c(1, 0), c(1, 1), c(0, 1))
))
toy_sfnet = as_sfnetwork(toy_segment)
plot(toy_sfnet, graticule = TRUE, axes = TRUE, cex = 2) is converted to a vertical straight segment from (0, 0) to (0, 1) when converted into spatstat format par(mar = rep(0, 4))
plot(as.linnet(toy_sfnet), main = "", vertices = TRUE) since you lose the intermediate segments, right? Created on 2022-05-25 by the reprex package (v2.0.1) |
Beta Was this translation helpful? Give feedback.
4 replies
-
Great! Many thanks.
Best wishes,
Michal
Dne pá 27. 5. 2022 17:29 uživatel Andrea Gilardi ***@***.***>
napsal:
… Ok, thanks! I think the ideal solution would be to develop a new spatial
morpher to perform exactly that operation. It shouldn't be extremely
difficult (since a similar operation is also performed by
to_spatial_subdivision). I will try to add a PR here as soon as possible.
—
Reply to this email directly, view it on GitHub
<#207 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AB5FYZNZ7WN7TXVJB2UQ6ELVMDS6FANCNFSM5W4R2V7A>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi!
I work with spatstat's linnet and derived classes, but I want to preprocess my data with sfnetworks. (I'm working with a road network.) Therefore, I need a way to convert a sfnetwork to linnet. I've stumbled across three ways to do it:
First, one can use as.linnet.sfnetwork(). This is fast and preserves the topology but doesn't work for my purposes as it replaces each edge with a straight line, dropping all spatial information about the paths.
Second, one can convert the edges to sf, sf to sp, and sp to linnet. Here, I found two solutions. One is
The problem with this solution is that it creates "lifts" in mixmasters, i.e., it creates new nodes and connects paths that weren't previously connected but geometrically crossed. This is happening, e.g., in off-grade intersections. I have no idea why it doesn't work correctly.
The other is very similar---only sp to linnet conversion differs:
This one seems to work ok.
I suggest mentioning this stuff in a vignette for other users.
Please let me know if the third solution is problematic, too, or if there is still a better way.
And many thanks to all developers of sfnetwork for their excellent work.
Best wishes,
Michal
Beta Was this translation helpful? Give feedback.
All reactions