Welcome back to this month’s edition of Mapping Class. The Mapping Class tutorial series curates video tutorials and workflows created by experienced cartographers and Avenza software users. Joining us once again is Steve Spindler, a longtime MAPublisher user, and expert cartographer. Steve is here to show you a quick tip for using the attribute expression builder within MAPublisher to quickly perform batch edits of labels.
Steve has produced a short video to demonstrate how he uses the expression builder to quickly edit street names. The Avenza team has produced video notes (below) to help you follow along.
***
Label efficiently using Attribute Expression Builder
by Steve Spindler (video notes by the Avenza team)
With MAPublisher, labeling your maps is a breeze. With powerful tools such as LabelPro, labeling is only a matter of selecting the data you want to label, and configuring a robust set of rules that control how each label is placed and styled. But before you can start labeling, you must have high-quality, accurate attribute information for your map data. Since labels are typically generated by displaying text values contained in an attribute column, it is important that attributes are not only accurate but are also formatted in a way that is optimized for display on a map. In many cases, cartographers need to spend time reformatting or editing attribute information before they can generate labels, a process that can become quite time-consuming. Nowhere else is this problem more common than when dealing with street names and road network data.
When labeling streets, cartographers often spend time correcting, or even generating brand new attribute information that can be used to create more concise, effective street labels. This typically involves changing street prefixes and suffixes to a condensed short form (i.e “North Cherry Boulevard” becomes “N Cherry Blvd”). For smaller projects, this can be done by manually editing the individual attribute values directly within the MAP Attribute panel. For large projects, especially those dealing with hundreds or even thousands of map features, manual editing would be very time-consuming.
For a more efficient approach, Steve shows how you can use the Expression Builder to easily modify large selections of attribute values. The first step is to open the MAP attribute table, which displays all the attribute information contained within a specific map layer. Steve identifies the attribute column that contains the text street names and will use this to build out a new attribute column to create his labels.
Next, Steve opens the Edit Schema window of the attribute table. Here, you can access column information such as the data type, default value, field visibility, and most importantly; the expression builder.
The expression builder may seem intimidating at first, but with a little bit of effort, it can be an incredibly powerful tool for calculating attribute values and performing batch-edits on your data. The tool uses built-in operators and items in the objects list (attribute names and values, constants, functions) to calculate custom attribute information based on a specified set of expressions. In this case, Steve first creates an expression set that modifies the suffix values in the Street name field (i.e “Boulevard”) and substitutes them with the appropriate short form (“Blvd”). The expression is used to populate a new attribute column called “Road_suffix”. The end result means attribute values such as “East Utica Street” will be passed to a new attribute value of “East Utica St”.
IF_CASE(name,
ENDSWITH(name, “ Street“),SUBSTITUTE( name , “Street”, “St”),
ENDSWITH(name, “ Drive“),SUBSTITUTE( name , “Drive”, “Dr”),
ENDSWITH(name, “ Road“),SUBSTITUTE( name , “Road”, “Rd”),
ENDSWITH(name, “ Court“),SUBSTITUTE( name , “Court”, “Ct”),
ENDSWITH(name, “ Way“),SUBSTITUTE( name , “Way”, “Wy”),
ENDSWITH(name, “ Lane“),SUBSTITUTE( name , “Lane”, “La”),
ENDSWITH(name, “ Route“),SUBSTITUTE( name , “Route”, “Rt”),
ENDSWITH(name, “ Boulevard“),SUBSTITUTE( name , “Boulevard”, “Blvd”),
ENDSWITH(name, “ Turnpike“),SUBSTITUTE( name , “Turnpike”, “Tpke”),
ENDSWITH(name, “ Avenue“),SUBSTITUTE( name , “Avenue”, “Ave”),
ENDSWITH(name, “ Place“),SUBSTITUTE( name , “Place”, “Pl”),
ENDSWITH(name, “ Circle“),SUBSTITUTE( name , “Court”, “Cr”),
ENDSWITH(name, “ Highway“),SUBSTITUTE( name , “Highway”, “Hwy”),
ENDSWITH(name, “ Expressway“),SUBSTITUTE( name , “Expressway”, “Exp”)
)
Next, Steve creates a second set of expressions that will further adjust his Road_suffix attribute column to substitute any street name prefixes (North, East, South, West) with their corresponding short-form (N, E, S, W). This second expression (see code block below) is used to populate another new attribute column called “Label”, which will ultimately be used to generate the final formatted label layer.
((IF_CASE( Road_suffix ,
STARTSWITH(Road_suffix, “West “), SUBSTITUTE( Road_suffix, “West “, “W “),
STARTSWITH(Road_suffix, “South “), SUBSTITUTE( Road_suffix, South “, “S “),
STARTSWITH(Road_suffix, “North “), SUBSTITUTE( Road_suffix, “North “, “N “),
STARTSWITH(Road_suffix, “East “), SUBSTITUTE( Road_suffix, “East “, “E “)
))
Note that these expressions are specific to the dataset and map area Steve is using for his project. When using expression builders for your own maps, pay careful attention to the attribute values specific to your area of interest. The best part about expression sets is that they are highly flexible, meaning you can build upon and modify existing expressions, save them to your library, and even use them across multiple different mapping projects!
With his newly created “Label” attribute column, it’s simply a matter of configuring the LabelPro tool to display these formatted label values. With a bit of configuration, the end result is a clean, uncluttered, collision-free label layer. The labels now use all the correct prefixes and suffixes Steve required. By saving his expression sets to his library folder, Steve can now quickly and easily repeat the exact same batch-editing process for new maps with only a few clicks!
***
About the Author
Steve Spindler has been designing compelling cartographic pieces for over 20 years. His company, Steve Spindler Cartography, has developed map products for governments, city planning organizations, and non-profits from across the country. He also manages wikimapping.com, a public engagement tool that allows city planners to connect and receive input from their community using maps. To learn more about Steve Spindler’s spectacular cartography work, visit his personal website. To view Steve’s other mapping demonstrations, visit cartographyclass.com