Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
desc_chemins
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maxime GUILLAUMIN
desc_chemins
Commits
0466a2d6
Commit
0466a2d6
authored
Mar 20, 2023
by
Maxime GUILLAUMIN
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
30981deb
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
main.py
+53
-0
53 additions, 0 deletions
main.py
with
53 additions
and
0 deletions
main.py
0 → 100644
+
53
−
0
View file @
0466a2d6
import
osmnx
as
ox
import
networkx
as
nx
import
geopandas
as
gpd
import
crseg.utils
as
u
import
crseg.segmentation
as
cs
import
json
import
crgraph
as
cg
import
SegmentationReader
as
sr
overpass
=
0
latitude
=
45.77417
longitude
=
3.09028
G1
=
u
.
Util
.
get_osm_data
(
latitude
,
longitude
,
1000
,
overpass
)
# prepare network by removing unwanted ways
G1
=
cs
.
Segmentation
.
prepare_network
(
G1
)
# build an undirected version of the graph
undirected_G
=
ox
.
utils_graph
.
get_undirected
(
G1
)
#working on non-oriented graph
G1
=
undirected_G
#adding new attributes to the graph
cg
.
prepare_graph_OSM
(
G1
)
# segment it using topology and semantic
seg
=
cs
.
Segmentation
(
undirected_G
,
C0
=
2
,
C1
=
2
,
C2
=
4
,
max_cycle_elements
=
10
)
seg
.
process
()
#exporting to json
seg
.
to_json_all
(
"
crossroads.json
"
)
#List of all the intersection and branch
seg_reader
=
sr
.
SegmentationReader
(
"
crossroads.json
"
)
#Create our new model
G
=
cg
.
create_graph_model
(
G1
,
seg_reader
)
#Add edges
cg
.
add_edges
(
G1
,
G
,
seg_reader
)
#visualization of the OSMnx graph
ox
.
plot_graph
(
G1
,
bgcolor
=
'
w
'
,
node_color
=
'
k
'
,
node_size
=
5
,
node_alpha
=
0.7
,
node_edgecolor
=
'
b
'
,
node_zorder
=
5
,
edge_color
=
'
r
'
,
edge_linewidth
=
2
,
edge_alpha
=
0.8
,
show
=
True
)
#visualization of the new model
ox
.
plot_graph
(
G
,
bgcolor
=
'
w
'
,
node_color
=
'
k
'
,
node_size
=
5
,
node_alpha
=
0.8
,
node_edgecolor
=
'
b
'
,
node_zorder
=
5
,
edge_color
=
'
r
'
,
edge_linewidth
=
2
,
edge_alpha
=
0.8
,
show
=
True
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment