Skip to content
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

Update get_osm_data script #241

Merged
merged 2 commits into from
Jan 16, 2025
Merged

Update get_osm_data script #241

merged 2 commits into from
Jan 16, 2025

Conversation

Grufoony
Copy link
Collaborator

New features:

  • Now filtering is done using osmnx features rather than my buggy filters :c
  • Intersection are now merged within a default radius of 20 meters (can be changed passing it as arg)
  • Duplicated edges are discarded by default to prevent conflict. If discarded, a temporary plot will be promped showing them in red
  • Script produces two files, i.e. the complete network and the network resulting from all filtering processes

@Grufoony Grufoony merged commit 886074f into main Jan 16, 2025
14 of 15 checks passed
@Grufoony Grufoony deleted the improve_osmFilter branch January 16, 2025 08:43
gdf_nodes, gdf_edges = ox.graph_to_gdfs(G)
# plot graph on a 16x9 figure and save into file
ox.plot_graph(GRAPH, show=False, close=True, save=True, filepath="./final.png")
gdf_nodes, gdf_edges = ox.graph_to_gdfs(ox.project_graph(GRAPH, to_latlong=True))

Check warning

Code scanning / Pylint (reported by Codacy)

Constant name "gdf_nodes" doesn't conform to UPPER_CASE naming style Warning

Constant name "gdf_nodes" doesn't conform to UPPER_CASE naming style
gdf_nodes, gdf_edges = ox.graph_to_gdfs(G)
# plot graph on a 16x9 figure and save into file
ox.plot_graph(GRAPH, show=False, close=True, save=True, filepath="./final.png")
gdf_nodes, gdf_edges = ox.graph_to_gdfs(ox.project_graph(GRAPH, to_latlong=True))

Check warning

Code scanning / Pylint (reported by Codacy)

Constant name "gdf_edges" doesn't conform to UPPER_CASE naming style Warning

Constant name "gdf_edges" doesn't conform to UPPER_CASE naming style
N_DUPLICATES = 0
else:
# Check for duplicate edges
duplicated_mask = gdf_edges.duplicated(subset=["u", "v"])

Check warning

Code scanning / Pylint (reported by Codacy)

Constant name "duplicated_mask" doesn't conform to UPPER_CASE naming style Warning

Constant name "duplicated_mask" doesn't conform to UPPER_CASE naming style
N_DUPLICATES,
)
# Plot the graph with duplicated edges in red
edge_colors = [

Check warning

Code scanning / Pylint (reported by Codacy)

Constant name "edge_colors" doesn't conform to UPPER_CASE naming style Warning

Constant name "edge_colors" doesn't conform to UPPER_CASE naming style
ox.plot_graph(GRAPH, edge_color=edge_colors)

# Remove duplicated edges
gdf_edges = gdf_edges.drop_duplicates(subset=["u", "v"])

Check warning

Code scanning / Pylint (reported by Codacy)

Constant name "gdf_edges" doesn't conform to UPPER_CASE naming style Warning

Constant name "gdf_edges" doesn't conform to UPPER_CASE naming style
# Save the data
gdf_nodes.to_csv("nodes.csv", sep=";", index=False)
gdf_edges.to_csv("edges.csv", sep=";", index=False)
place = parser.place.split(",")[0].strip().lower()

Check warning

Code scanning / Pylint (reported by Codacy)

Constant name "place" doesn't conform to UPPER_CASE naming style Warning

Constant name "place" doesn't conform to UPPER_CASE naming style
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant