---
title: Tools/District
permalink: /Tools/District/
---

## districts2poly.py

Transform
[districts](../Demand/Importing_O/D_Matrices.md#describing_the_taz)
into polygons for visualization in [SUMO-GUI](../SUMO-GUI.md).
Using the options **--hue, --saturation, --brightness** the colors can be controlled. Each of these options
supports values from \[0, 1\] as well as the special value *random*.

```
<SUMO_HOME>/tools/districts2poly.py myNet.net.xml myDistricts.rou.xml
```

!!! caution
    Only districts using the attribute `edges` are currently supported

## edgesInDistricts.py

Parsing a number of networks and taz (district) files with shapes this
script writes a taz file with all the edges which are inside the
relevant taz. The taz files must be in the format generated by
[POLYCONVERT](../POLYCONVERT.md).

```
<SUMO_HOME>/tools/edgesInDistricts.py -n myNet.net.xml -t myDistrictPolygons.add.xml
```

Call option **--help** for additional details.

## filterDistricts.py

Filter a taz (district) file using a network file and a vehicle class so
that only edges which allow the given vehicle class are included in the
taz definitions.

```
<SUMO_HOME>/tools/district/filterDistricts.py -n myNet.net.xml -t myDistricts.add.xml -o filteredDistricts.add.xml --vclass passenger
```

Call option **--help** for additional details.

## generateBidiDistricts.py

Finds edges that are opposites of each other and puts them in a common
district (TAZ). This can be used to improve routing in conjunction with
[trip attributes fromTaz and
toTaz](../Definition_of_Vehicles,_Vehicle_Types,_and_Routes.md#traffic_assignement_zones_taz).

```
<SUMO_HOME>/tools/generateBidiDistricts.py myNet.net.xml
```

Call option **--help** for additional details.

### Example usage

When applied to a typical OSM network, and edge and the edge with the
negated id describe opposite direction edges of the same road. The
generated bidi-taz would look like this:

```
<taz id="-123" edges="-123 123"/>
<taz id="123" edges="-123 123"/>
```

The `<trip>` definitions that would typically use attributes *from* and *to*
instead use the attributes *fromTaz* and *toTaz*:

```
<trip id="someTrip" from="123" to="456" depart="0"/>
<trip id="someTripWithBidiTaz fromTaz="123" toTaz="456"/>
```

The second definition would allow departure from either edge *123*' or
*-123* **due to the way the taz *123* ** is definied. This can prevent
unwanted turn-arounds and the beginning and end of generated trips and
thus simplifies trips created from mapping of geo-coordinates.