Skip to content

Commit

Permalink
test sfnetwoorks smooth
Browse files Browse the repository at this point in the history
#1
still need to integrate in functions
  • Loading branch information
temospena committed Feb 16, 2024
1 parent b7293c1 commit 3a621ba
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
6 changes: 3 additions & 3 deletions _targets.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@


# Set defaults HERE ######################
CITY_input = "Almada"
cellsize_input = c(300, 300)
square_input = TRUE #TRUE = squares, FALSE = hexagons
CITY_input = "Lisboa"
cellsize_input = c(500, 500)
square_input = FALSE #TRUE = squares, FALSE = hexagons


#########################################
Expand Down
23 changes: 22 additions & 1 deletion code/centrality.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,28 @@ road_network = st_read("database/lisbon_network_vclean.gpkg") #or https://github
#
# # TESTE rede gabriel
# road_network = st_read("database/old_network/RedeViariaLisboa_osm_Setores/RedeViariaLisboa_osm_Setores.shp")
# road_network = st_transform(road_network, 3857) # Project

# TESTE rede limpa osm targets
road_network = st_read("outputdata/Lisboa/road_network_clean.shp")



net = as_sfnetwork(road_network)
smoothed = convert(net, to_spatial_smooth)

nodes_smoothed = smoothed %>%
activate(nodes) %>%
as_tibble() |>
st_as_sf(coords = c('X', 'Y')) %>%
st_set_crs(st_crs(edges))



road_network = st_transform(road_network, 3857) # Project

# create a road network graph ------------------------------------------------------------


edges = road_network %>%
mutate(edgeID = c(1:n()))

Expand Down Expand Up @@ -60,6 +77,10 @@ nodes = nodes %>%
st_set_crs(st_crs(edges))






# Convert Sticky Geometry (sf) and Linestring geometries into a tbl_graph
graph = tbl_graph(nodes = nodes, edges = as_tibble(edges), directed = FALSE)

Expand Down

0 comments on commit 3a621ba

Please sign in to comment.