Deltares / ra2ce

RA2CE helps to quantify resilience of critical infrastructure networks, prioritize interventions and adaptation measures and select the most appropriate action perspective to increase resilience considering future conditions.
https://deltares.github.io/ra2ce/
Other
9 stars 2 forks source link

reprojecting graph does not update the NetwporkX graph crs #542

Closed Cham8920 closed 1 month ago

Cham8920 commented 1 month ago

Ra2ce version checks

Reproducible example

Damages workflow uses the columns highway(to get road type) and lanes for the calculations. When I used a shp file for the road network (not from osm) the final graph network didn't contain the highway column

Current behaviour

I think the problem is here: ra2ce\ra2ce\network\network_wrappers\vector_network_wrapper.py line 85,90 to include highways and lanes in the final network

    gdf = self._read_vector_to_project_region_and_crs()
    gdf = self.clean_vector(gdf)
    if self.directed:
        graph = self._get_direct_graph_from_vector(
            gdf=gdf, edge_attributes_to_include=["avgspeed", "bridge", "tunnel"]
        )
    else:
        graph = self._get_undirected_graph_from_vector(
            gdf, edge_attributes_to_include=["avgspeed", "bridge", "tunnel"]

Desired behaviour

It worled when I changed here: ra2ce\ra2ce\network\network_wrappers\vector_network_wrapper.py line 85,90 to include highways and lanes in the final network

    gdf = self._read_vector_to_project_region_and_crs()
    gdf = self.clean_vector(gdf)
    if self.directed:
        graph = self._get_direct_graph_from_vector(
            gdf=gdf, edge_attributes_to_include=["avgspeed", "bridge", "tunnel"**,"highway","lanes"**]
        )
    else:
        graph = self._get_undirected_graph_from_vector(
            gdf, edge_attributes_to_include=["avgspeed", "bridge", "tunnel",**"highway","lanes"**]

When I did this , it still created a blank column so I made a change to the \ra2ce\ra2ce\runners\damages_analysis_runner.py in line 131-132 because the blank column gave me some trouble.

event_cols = [ col for col in result_segmentbased.columns if (len(col) > 1 and col[0].isupper() and col[1] == "")

if (col[0].isupper() and col[1] == "_")

    ]
    events = set([x.split("_")[1] for x in event_cols])  # set of unique event

Additional context

No response

sahand-asgarpour commented 1 month ago

Ra2ce version checks

* [x]  I have checked that this issue has not already been reported.

* [x]  I have checked that this bug exists on the latest version of Ra2ce in `master` [here](https://github.com/Deltares/ra2ce).

Reproducible example

Damages workflow uses the columns highway(to get road type) and lanes for the calculations. When I used a shp file for the road network (not from osm) the final graph network didn't contain the highway column

Current behaviour

I think the problem is here: ra2ce\ra2ce\network\network_wrappers\vector_network_wrapper.py line 85,90 to include highways and lanes in the final network

    gdf = self._read_vector_to_project_region_and_crs()
    gdf = self.clean_vector(gdf)
    if self.directed:
        graph = self._get_direct_graph_from_vector(
            gdf=gdf, edge_attributes_to_include=["avgspeed", "bridge", "tunnel"]
        )
    else:
        graph = self._get_undirected_graph_from_vector(
            gdf, edge_attributes_to_include=["avgspeed", "bridge", "tunnel"]

Desired behaviour

It worled when I changed here: ra2ce\ra2ce\network\network_wrappers\vector_network_wrapper.py line 85,90 to include highways and lanes in the final network

    gdf = self._read_vector_to_project_region_and_crs()
    gdf = self.clean_vector(gdf)
    if self.directed:
        graph = self._get_direct_graph_from_vector(
            gdf=gdf, edge_attributes_to_include=["avgspeed", "bridge", "tunnel"**,"highway","lanes"**]
        )
    else:
        graph = self._get_undirected_graph_from_vector(
            gdf, edge_attributes_to_include=["avgspeed", "bridge", "tunnel",**"highway","lanes"**]

When I did this , it still created a blank column so I made a change to the \ra2ce\ra2ce\runners\damages_analysis_runner.py in line 131-132 because the blank column gave me some trouble.

event_cols = [ col for col in result_segmentbased.columns if (len(col) > 1 and col[0].isupper() and col[1] == "") #if (col[0].isupper() and col[1] == "") ] events = set([x.split("")[1] for x in event_cols]) # set of unique event

Additional context

No response

This is not an error. link_type_column and file_id attributes should be filled in as 'highway' and .

Here a commit is pushed that updates the reprojected crs.