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
7 stars 1 forks source link

Creating network from shapefile cannot handle lists #434

Open LiekeMeijer opened 2 months ago

LiekeMeijer commented 2 months ago

Ra2ce version checks

Reproducible example

When creating a network from a shapefile which is an OSM-download converted into a shapefile (available upon request because I cannot upload it here).

Current behaviour

Exception has occurred: TypeError
unhashable type: 'list'
  File "C:\python\ra2ce\ra2ce\network\networks_utils.py", line 1680, in graph_link_simple_id_to_complex
    lookup_dict[key_1] = value_1
  File "C:\python\ra2ce\ra2ce\network\networks_utils.py", line 996, in create_simplified_graph
    simple_to_complex, complex_to_simple = graph_link_simple_id_to_complex(
  File "C:\python\ra2ce\ra2ce\network\network_wrappers\vector_network_wrapper.py", line 98, in get_network
    graph_simple, graph_complex, link_tables = nut.create_simplified_graph(
  File "C:\python\ra2ce\ra2ce\network\network_wrappers\network_wrapper_factory.py", line 61, in get_network
    return VectorNetworkWrapper(self._config_data).get_network()
  File "C:\python\ra2ce\ra2ce\network\networks.py", line 220, in _get_new_network_and_graph
    ).get_network()
  File "C:\python\ra2ce\ra2ce\network\networks.py", line 292, in create
    self._get_new_network_and_graph(to_save)
  File "C:\python\ra2ce\ra2ce\network\network_config_wrapper.py", line 89, in configure_network
    self.graph_files = network.create()
  File "C:\python\ra2ce\ra2ce\network\network_config_wrapper.py", line 84, in configure
    self.configure_network()
  File "C:\python\ra2ce\ra2ce\configuration\config_wrapper.py", line 71, in configure
    self.network_config.configure()
  File "C:\python\ra2ce\ra2ce\ra2ce_handler.py", line 153, in configure
    self.input_config.configure()
  File "C:\Users\meije_le\AppData\Local\Temp\ipykernel_49144\285750240.py", line 3, in <module>
    handler.configure()
TypeError: unhashable type: 'list'

Desired behaviour

Handling the lists or seperating them so that they do not result in crashes. OSM data can contain lists instead of one value. for example for road types it can be ['secondary, tertiary']. This probably happens when the attribute is a bit uncertain and it happens in all kinds of columns and rows. We need to think about how to handle these data types.

Additional context

No response

Carsopre commented 1 month ago

@LiekeMeijer could you please provide somewhere (N: Drive? or your postbox?) The used shapefile that reproduces this error? Is it a 'sensible' shapefile or can it be uploaded to our solution as a test?