Package: network-wrangler
network_wranglerNetwork Wrangler is a Python library for managing travel model network scenarios.System RequirementsNetwork Wrangler should be operating system agonistic and has been tested on Ubuntu and Mac OS.In order to assist in installation, its helpful to have eitherminiconda,anacondaorDocker CEinstalled.  If you don't have any of these already, we reommend starting with Miniconda for Python 3.7 as it has the smallest footprint.condais the environment manager that is contained within both the Anaconda and mini-conda applications. All commands described below should be entered into theAnanconda Promptcommand window.Network Wrangler does require Python 3.7+.  If you have a different version of Python installed,condawill take care of installing it for you in the installation instructions below.InstallationNetwork Wrangler uses Python 3.6 and above.  Requirements are stored inrequirements.txtbut are automatically installed when usingpip.If you are managing multiple python versions, we suggest usingvirtualenvorcondavirtual environments.condais the environment manager that is contained within both the Anaconda and mini-conda applications. Do not add Anaconda to the system path during installation. This may cause problems with other programs that require python 2.7 to be placed in the system path.Example installing and running tests using conda in the command line:condaconfig--addchannelsconda-forge
condacreatepython=3.7rtreegeopandasosmnx-n<my_wrangler_environment>
condaactivate<my_wrangler_environment>
pipinstallnetwork-wrangler
pytest-s-mtravisNetwork wrangler can be installed in several ways depending on the user's needs. Installing from github is the simplest method and is appropriate when the user does not anticipate needing to update network wrangler. An update will require rebuilding the network wrangler environment. Installing from clone is slightly more involved and requires the user to have a git manager on their machine, but permits the user to install network wrangler with the-e, edit, option so that their network wrangler installation can be updated through pulling new commits from the network wrangler repo without a full reinstallation.From GitHubUse the package managerpipto install Network Wrangler from the source on GitHub.condaconfig--addchannelsconda-forge
condacreatepython=3.7rtreegeopandasosmnx-n<my_wrangler_environment>
condaactivate<my_wrangler_environment>
pipinstallgit+https://github.com/wsp-sag/network_wrangler.git@master#egg=network_wranglerNote: if you wanted to install from a specific tag/version number or branch, replace@masterwith@<branchname>or@tagFrom CloneIf you are going to be working on Network Wrangler locally, you might want to clone it to your local machine and install it from the clone.  The -e will install it ineditable mode.This is also useful if you want to continue to update your Network Wrangler as it is developed on GitHub.1. Open a terminal to get a command prompt.2. Consider using a virtual environment manager like conda.Create a new environment by typing the following commands into the command prompt (it might take a few minutes).condacreatepython=3.7-nwrangler_env
condaactivatewrangler_envI chosewrangler_envas the name of my environment, but you could choose something else...just remember it so that you can access it later.NOTEin order to get back to "this" conda environment (i.e. after you close this command prompt), you will need to access it from the command line by using the following command:condaactivatewrangler_env3. Install finicky RequirementsSome requirements are best installed using conda rather than "pip"condaconfig--addchannelsconda-forge
condainstallrtreegeopandasosmnx4. "Clone" (aka download) network wrangler from Github on to your machineIf you haveGitHub desktopinstalled, you can either do this by using the GitHub user interface by clicking on the green button "clone or download" in themain network wrangler repository page.Otherwise, you can use the command prompt to navigate to the directory that you would like to store your network wrangler clone and then using agit commandto clone it.cdpathtowhereyouwanttoputwrangler
gitclonehttps://github.com/wsp-sag/network_wranglerExpected output:cloningintonetwork_wrangler...
remote:Enumeratingobjects:53,done.
remote:Countingobjects:100%(53/53),done.
remote:Compressingobjects:100%(34/34),done.
remote:Total307(delta28),reused29(delta19),pack-reused254Receivingobjects:100%(307/307),15.94MiB|10.49MiB/s,done.
Resolvingdeltas:100%(140/140),done.5. Install Network Wrangler in "develop" mode.Navigate your command prompt into the network wrangler folder and then install network wrangler in editable mode.
This will take a few minutes because it is also installing all the prerequisites.cdnetwork_wrangler
pipinstall-e.There will be a lot of messy output, but it should end with something like:Runningsetup.pydevelopfornetwork-wrangler
SuccessfullyinstalledRtree-0.8.3attrs-19.1.0cchardet-2.1.4chardet-3.0.4click-7.0click-plugins-1.1.1cligj-0.5.0cycler-0.10.0decorator-4.4.0descartes-1.1.0fiona-1.8.6geojson-2.4.1geopandas-0.5.1idna-2.8isoweek-1.3.3jsonschema-3.0.2kiwisolver-1.1.0matplotlib-3.1.1munch-2.3.2network-wranglernetworkx-2.3numpy-1.17.0osmnx-0.10pandas-0.25.0partridge-1.1.0pyparsing-2.4.2pyproj-2.2.1pyrsistent-0.15.4python-dateutil-2.8.0pytz-2019.2pyyaml-5.1.2requests-2.22.0shapely-1.6.4.post2six-1.12.0urllib3-1.25.36. Test the InstallationYou can test that network wrangler was properly installed by running the tests as follows:pytest-s-mtravisUsing the-sflag will run all the tests in "noisy" mode.
The-m travisflag runs only tests that are marked as for "travis" continuous  integrationNote: if you are not part of the project team and want to contribute code back to the project, please fork before you clone and then add the original repository to your upstream origin list perthese directions on github.Using DockerInstallDockerClone git repository (see instructions above)NOTE: this is easiest way right now since repo is private. When it is public we can clone right from github without having to muck around with logins or keysFrom the cloned repository, open a terminal from the/dockerfolder and build and run the docker container corresponding to what you want to do by runningdocker-compose run <container name> <entry point (optional)> --buildCommand to exit container:exitContainers:wrangler-jupyterstarted by runningdocker-compose run wrangler-jupyter --buildis appropriate for running and testing wrangler.Default action is to startjupyter notebookwhich can be found athttp://127.0.0.1:8888Safe: It creates an empty folder to store jupyter notebooks within the container but wont overwrite the source files on your actual machine.Starting Bash: You can also start the container with a command line usingdocker-compose run wrangler-jupyter /bin/bash --build.Doesn't install development dependencies (although they can be installed from within the container)wrangler-ciis a small image without extras meant for running tests and deploying to continuous integration server.default command is to runpytest.contains development dependencies so that it can run tests and build docs.wrangler-devis the most powerful but dangerous containerdocker-compose run wrangler-dev /bin/bash --buildWarning: It will synchronize code edited from the container to your wrangler clone.  This is great for developing within an IDE, but please take this into account.Common Installation IssuesIssue:clang: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of OS X 10.9 [-Wdeprecated]If you are using MacOS, you might need to update yourxcode command line tools and headersIssue:OSError: Could not find libspatialindex_c library file*
Try installing rtree on its own from the Anaconda cloudcondainstallrtreeIssue: Shapely, a pre-requisite, doesn't install propertly because it is missing GEOS moduleTry installing shapely on its own from the Anaconda cloudcondainstallshapelyIssue: Conda is unable to install a library or to update to a specific library versionTry installing libraries from conda-forgecondainstall-cconda-forge*library*Issue: User does not have permission to install in directoriesTry running Anaconda Prompt as an administrator.QuickstartTo get a feel for the API and using project cards, please refer to the "Wrangler Quickstart" jupyter notebook.To start the notebook, open a command line in the network_wrangler top-level directory and type:jupyter notebookDocumentationDocumentation can be built from the/docsfolder using the command:make htmlUsageimportnetwork_wrangler##todo this is just an example for now## Network Manipulationmy_network=network_wrangler.read_roadway_network(...)# returnsmy_network.apply_project_card(...)# returnsmy_network.write_roadway_network(...)# returns## Scenario Buildingmy_scenario=scenario_from_network(roadway_network,transit_network)my_scenario.add_projects(directory,keyword)my_scenario.write_networks(directory,format)AttributionThis project is built upon the ideas and concepts implemented in thenetwork wrangler projectby theSan Francisco County Transportation Authorityand expanded upon by theMetropolitan Transportation Commission.While Network Wrangler as written here is based on these concepts, the code is distinct and builds upon other packages such asgeopandasandpartridgewhich hadn't been implemented when networkwrangler 1.0 was developed.ContributingPull requests are welcome. Please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.LicenseApache-2.0