Working with Attributes
On of the strength of Via is its flexibility in visualizing data based on different attribute values. For example, vehicles can vary in symbol, size and color, thus allowing to show the vehicle type, number of passengers and current vehicle speed all at once. Links can by styled in color, width, transparency to show information about number of lanes, capacity, current travel demand, average speed on the link etc.
For non-numerical attributes, a pattern-matching approach is available where the asterisk (*
) acts as wildcard character, matching any number of any other characters. This can be used for example to match any link in a network containing the mode walk by using the pattern walk.
For numerical attributes, different colors can be assigned to specific values. Then, for values in-between, the color can either be interpolated or not. If the colors are not interpolated, the specified values typically act as the lower boundary for the color specified, only with the exception of the smallest value whose color is also used for values smaller than it.
Missing values
If an element with a numerical attribute has no value assigned, the value NaN
(not a number) will be shown. Equally, NaN
can be entered as a value to style elements where the attribute value is missing.
Custom Attributes
For many layers, you can load additional, custom attributes. Such custom attributes can either be loaded from simple CSV (comma separated values) files, TXT files (tab separated), or from MATSim’s ObjectAttributes files.
Example CSV file:
AGENT_ID, NAME, AGE
123,John,22
234,Cindy,25
345,Bill,32
To create the same data in MATSim as an ObjectAttribute file:
ObjectAttributes personAttributes = new ObjectAttributes();
personAttributes.putAttribute(person1.getId().toString(), "NAME", "John");
personAttributes.putAttribute(person1.getId().toString(), "AGE", 22);
personAttributes.putAttribute(person2.getId().toString(), "NAME", "Cindy");
personAttributes.putAttribute(person2.getId().toString(), "AGE", 25);
personAttributes.putAttribute(person3.getId().toString(), "NAME", "Bill");
personAttributes.putAttribute(person3.getId().toString(), "AGE", 32);
new ObjectAttributesXmlWriter(personAttributes).writeFile(“myPersonAttributes.xml.gz”);