.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_auto_examples/path_computation/plot_skimming.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr__auto_examples_path_computation_plot_skimming.py: .. _example_usage_skimming: Network skimming ================ In this example, we show how to perform network skimming for Coquimbo, a city in La Serena Metropolitan Area in Chile. .. GENERATED FROM PYTHON SOURCE LINES 27-32 .. seealso:: Several functions, methods, classes and modules are used in this example: * :func:`aequilibrae.paths.Graph` * :func:`aequilibrae.paths.NetworkSkimming` .. GENERATED FROM PYTHON SOURCE LINES 34-41 .. code-block:: Python # Imports from uuid import uuid4 from tempfile import gettempdir from os.path import join from aequilibrae.utils.create_example import create_example .. GENERATED FROM PYTHON SOURCE LINES 43-49 .. code-block:: Python # We create the example project inside our temp folder fldr = join(gettempdir(), uuid4().hex) project = create_example(fldr, "coquimbo") .. GENERATED FROM PYTHON SOURCE LINES 50-53 .. code-block:: Python import logging import sys .. GENERATED FROM PYTHON SOURCE LINES 54-55 When the project opens, we can tell the logger to direct all messages to the terminal as well .. GENERATED FROM PYTHON SOURCE LINES 55-61 .. code-block:: Python logger = project.logger stdout_handler = logging.StreamHandler(sys.stdout) formatter = logging.Formatter("%(asctime)s;%(levelname)s ; %(message)s") stdout_handler.setFormatter(formatter) logger.addHandler(stdout_handler) .. GENERATED FROM PYTHON SOURCE LINES 62-64 Network Skimming ---------------- .. GENERATED FROM PYTHON SOURCE LINES 66-68 .. code-block:: Python import numpy as np .. GENERATED FROM PYTHON SOURCE LINES 69-70 Let's build all graphs .. GENERATED FROM PYTHON SOURCE LINES 70-74 .. code-block:: Python project.network.build_graphs() # We get warnings that several fields in the project are filled with ``NaN``s. # This is true, but we won't use those fields. .. rst-class:: sphx-glr-script-out .. code-block:: none 2025-06-17 01:06:18,804;WARNING ; Field(s) speed, travel_time, capacity, osm_id, lanes has(ve) at least one NaN value. Check your computations /home/runner/work/aequilibrae/aequilibrae/aequilibrae/paths/graph.py:248: UserWarning: Found centroids not present in the graph! [ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133] warnings.warn("Found centroids not present in the graph!\n" + str(centroids[~present_centroids])) 2025-06-17 01:06:18,881;WARNING ; Field(s) speed, travel_time, capacity, osm_id, lanes has(ve) at least one NaN value. Check your computations 2025-06-17 01:06:18,973;WARNING ; Field(s) speed, travel_time, capacity, osm_id, lanes has(ve) at least one NaN value. Check your computations 2025-06-17 01:06:19,060;WARNING ; Field(s) speed, travel_time, capacity, osm_id, lanes has(ve) at least one NaN value. Check your computations /home/runner/work/aequilibrae/aequilibrae/aequilibrae/paths/graph.py:248: UserWarning: Found centroids not present in the graph! [ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133] warnings.warn("Found centroids not present in the graph!\n" + str(centroids[~present_centroids])) .. GENERATED FROM PYTHON SOURCE LINES 75-76 We grab the graph for cars .. GENERATED FROM PYTHON SOURCE LINES 76-92 .. code-block:: Python graph = project.network.graphs["c"] # we also see what graphs are available project.network.graphs.keys() # let's say we want to minimize the distance graph.set_graph("distance") # And will skim distance while we are at it, other fields like ``free_flow_time`` or ``travel_time`` # can be added here as well graph.set_skimming(["distance"]) # But let's say we only want a skim matrix for nodes 28-40, and 49-60 (inclusive), # these happen to be a selection of western centroids. graph.prepare_graph(np.array(list(range(28, 41)) + list(range(49, 91)))) .. rst-class:: sphx-glr-script-out .. code-block:: none 2025-06-17 01:06:19,354;WARNING ; Field(s) speed, travel_time, capacity, osm_id, lanes has(ve) at least one NaN value. Check your computations .. GENERATED FROM PYTHON SOURCE LINES 93-94 And run the skimming .. GENERATED FROM PYTHON SOURCE LINES 94-96 .. code-block:: Python skm = graph.compute_skims() .. rst-class:: sphx-glr-script-out .. code-block:: none : 0%| | 0/55 [00:00` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_skimming.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_skimming.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_