.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_auto_examples/network_manipulation/plot_create_from_gmns.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_network_manipulation_plot_create_from_gmns.py: .. _import_from_gmns: Create project from GMNS ======================== In this example, we import a simple network in GMNS format. The source files of this network are publicly available in the `GMNS GitHub repository `_ itself. .. GENERATED FROM PYTHON SOURCE LINES 29-32 .. admonition:: References * :ref:`importing_from_gmns_file` .. GENERATED FROM PYTHON SOURCE LINES 34-38 .. seealso:: Several functions, methods, classes and modules are used in this example: * :func:`aequilibrae.project.Network.create_from_gmns` .. GENERATED FROM PYTHON SOURCE LINES 40-50 .. code-block:: Python # Imports from uuid import uuid4 from os.path import join from tempfile import gettempdir from aequilibrae import Project from aequilibrae.parameters import Parameters import folium .. GENERATED FROM PYTHON SOURCE LINES 52-58 .. code-block:: Python # We load the example file from the GMNS GitHub repository link_file = "https://raw.githubusercontent.com/zephyr-data-specs/GMNS/main/examples/Arlington_Signals/link.csv" node_file = "https://raw.githubusercontent.com/zephyr-data-specs/GMNS/main/examples/Arlington_Signals/node.csv" use_group_file = "https://raw.githubusercontent.com/zephyr-data-specs/GMNS/main/examples/Arlington_Signals/use_group.csv" .. GENERATED FROM PYTHON SOURCE LINES 59-66 .. code-block:: Python # We create the example project inside our temp folder fldr = join(gettempdir(), uuid4().hex) project = Project() project.new(fldr) .. rst-class:: sphx-glr-script-out .. code-block:: none No pre-existing parameter file exists for this project. Will use default No pre-existing parameter file exists for this project. Will use default .. GENERATED FROM PYTHON SOURCE LINES 67-70 In this cell, we modify the AequilibraE parameters.yml file so it contains additional fields to be read in the GMNS link and/or node tables. Remember to always keep the "required" key set to False, since we are adding a non-required field. .. GENERATED FROM PYTHON SOURCE LINES 70-84 .. code-block:: Python new_link_fields = { "bridge": {"description": "bridge flag", "type": "text", "required": False}, "tunnel": {"description": "tunnel flag", "type": "text", "required": False}, } new_node_fields = { "port": {"description": "port flag", "type": "text", "required": False}, "hospital": {"description": "hospital flag", "type": "text", "required": False}, } par = Parameters() par.parameters["network"]["gmns"]["link"]["fields"].update(new_link_fields) par.parameters["network"]["gmns"]["node"]["fields"].update(new_node_fields) par.write_back() .. GENERATED FROM PYTHON SOURCE LINES 85-88 As it is specified that the geometries are in the coordinate system EPSG:32619, which is different than the system supported by AequilibraE (EPSG:4326), we inform the srid in the method call: .. GENERATED FROM PYTHON SOURCE LINES 88-92 .. code-block:: Python project.network.create_from_gmns( link_file_path=link_file, node_file_path=node_file, use_group_path=use_group_file, srid=32619 ) .. rst-class:: sphx-glr-script-out .. code-block:: none Fields not imported from node table: wkt_coord. If you want them to be imported, please modify the parameters.yml file. .. GENERATED FROM PYTHON SOURCE LINES 93-96 Now, let's plot a map. This map can be compared with the images of the README.md file located in this example repository on GitHub: https://github.com/zephyr-data-specs/GMNS/blob/develop/examples/Arlington_Signals/README.md .. GENERATED FROM PYTHON SOURCE LINES 96-99 .. code-block:: Python links = project.network.links.data nodes = project.network.nodes.data .. GENERATED FROM PYTHON SOURCE LINES 100-106 .. code-block:: Python map = links.explore(color="black", style_kwds={"weight": 2}, tool_tip="link_type", name="links") map = nodes.explore(m=map, color="red", style_kwds={"radius": 5, "fillOpacity": 1.0}, name="nodes") folium.LayerControl().add_to(map) # Add a layer control button to our map map .. raw:: html
Make this Notebook Trusted to load map: File -> Trust Notebook


.. GENERATED FROM PYTHON SOURCE LINES 107-108 .. code-block:: Python project.close() .. rst-class:: sphx-glr-script-out .. code-block:: none This project at /tmp/dd7b00a6f5f842438490853cc7f36b1d is already closed .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.649 seconds) .. _sphx_glr_download__auto_examples_network_manipulation_plot_create_from_gmns.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_create_from_gmns.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_create_from_gmns.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_create_from_gmns.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_