mkoohafkan / mkoohafkan.github.io

My research blog.
http://hydroecology.net
MIT License
0 stars 1 forks source link

2020-05-16-generating-networks-from-rasters-with-r #44

Open mkoohafkan opened 4 years ago

mkoohafkan commented 4 years ago

Comments on https://hydroecology.net/generating-networks-from-rasters-with-r/

gvanhavre commented 2 years ago

Hello, do you have any idea how to avoid the wrapping effect? The resulting network seems to link easternmost to westernmost cells.

mkoohafkan commented 2 years ago

@gvanhavre not sure what you mean, I don't get those connections with the example I posted. Are you using a geographic coordinate system or a projected coordinate system? If you are using a geographic (latitude/longitude) coordinate system that may be causing the issue since adjacency() may treat the raster surface as sphere in that case.

library(ggraph)
coords = select(as_tibble(g, "nodes"), x ,y)
ggraph(g, layout = "manual", circular = FALSE, x = coords$x, y = coords$y) +
  geom_node_point() + 
  geom_edge_link()

image

gvanhavre commented 2 years ago

Sorry, my mistake. For some reason I'm still trying to understand, the network was folding in some troubling Lorenz' strange attractor pattern. In fact, I'm trying to use nodes values as edges values, in order to calculate multiple Least-Cost Paths.