.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_auto_examples/plot_tradesman_model.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_plot_tradesman_model.py: Create model ============ In this example, we show how to run a complete Tradesman model for Nauru, an insular country in Oceania. .. GENERATED FROM PYTHON SOURCE LINES 9-10 Imports .. GENERATED FROM PYTHON SOURCE LINES 10-15 .. code-block:: default from tradesman.model import Tradesman from tempfile import gettempdir from uuid import uuid4 from os.path import join .. GENERATED FROM PYTHON SOURCE LINES 16-17 We create a temporary folder to store our data .. GENERATED FROM PYTHON SOURCE LINES 17-19 .. code-block:: default folder = join(gettempdir(), uuid4().hex) .. GENERATED FROM PYTHON SOURCE LINES 20-21 Let's initialize our model .. GENERATED FROM PYTHON SOURCE LINES 21-23 .. code-block:: default model = Tradesman(network_path=folder, model_place="Nauru") .. GENERATED FROM PYTHON SOURCE LINES 24-26 If we want to run a model with Tradesman default configurations, we can go for `model.create()` and wait for it. But we can customize the model we want to create. So let's check out how to change some of the configurations. .. GENERATED FROM PYTHON SOURCE LINES 28-29 First step is to add the model area and other geographical subdivisions to our model .. GENERATED FROM PYTHON SOURCE LINES 29-33 .. code-block:: default model.import_model_area() model.add_country_borders() model.import_subdivisions() .. GENERATED FROM PYTHON SOURCE LINES 34-35 We can now import the network to our model. We'll download our network from OpenStreetMaps (OSM). .. GENERATED FROM PYTHON SOURCE LINES 35-37 .. code-block:: default model.import_network() .. GENERATED FROM PYTHON SOURCE LINES 38-39 Later we import population data into our model. We use WorldPop as our source, but you can also try Meta. .. GENERATED FROM PYTHON SOURCE LINES 39-41 .. code-block:: default model.import_population() .. rst-class:: sphx-glr-script-out .. code-block:: none pop_Nauru.tif: 0.00B [00:00, ?B/s] pop_Nauru.tif: 62%|######2 | 8.00k/12.9k [00:00<00:00, 17.9kB/s] pop_Nauru.tif: 100%|##########| 16.0k/16.0k [00:00<00:00, 35.7kB/s] .. GENERATED FROM PYTHON SOURCE LINES 42-44 Now that we have network and population information, we can build our Traffic Analysis Zones (TAZs). Nauru has a small population, so we will set our zones to range between 100 and 500 inhabitants. .. GENERATED FROM PYTHON SOURCE LINES 44-46 .. code-block:: default model.build_zoning(min_zone_pop=100, max_zone_pop=500) .. rst-class:: sphx-glr-script-out .. code-block:: none Expect 868 total hexbins for this bounding box 0%| | 0/31 [00:00` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_tradesman_model.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_