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. With us today is Steve Spindler, a MAPublisher expert, and professional cartographer. Steve is back with a quick demo showing how he uses MAPublisher path utility tools and a custom Adobe script produced by Nathaniel Kelso to create unique mile marker symbols. The Avenza team has produced video notes adapted from the original article found on Steve’s personal blog.
***
Create Distance Marker Symbols in MAPublisher using Scripts by Steve Spindler (Notes adapted from the original)
MAPublisher used within Adobe Illustrator enables us to create mile markers or other points along a line. I’m using this tool while working on the Genesee Valley Greenway map, and this video walks through the process.
Not shown in the video is how I set the direction of the line. Reversing the line direction is done using the MAPublisher Flip Lines tool. I just didn’t need to do this.
To set the mile marker preferences, we can use the Add Path Intervals in the Path Utilities tool.
This is pretty good, but if you want to customize the circle or square, it helps to convert the polygon objects into symbols.
Find and Replace Symbols Script
The script is called “Find and Replace Graphics” and can be found on Nathaniel Kelso’s website here. Save the script into the appropriate Adobe Illustrator Scripts folder. If you prefer, you can save the script elsewhere and navigate to the script manually using “File>Script>Other Script…”
Note: Save the script with the “.js” extension
To use it, I select all of the current objects that I want to replace and make sure they are on the same layer. I lock other layers. Then I add place a symbol on the same layer (ensure the symbol you want to use is the top-most object in the layer).
With the objects selected, run the script here.
All of the selected objects will be changed to the top-most object, which I set to be a symbol.
Select only the polygons, not the text. Otherwise, you will get this error.
***
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
This post was contributed by Hans van der Maarel of Red Geographics.
The problem with using GIS data for point symbols is that depending on the scale and symbolization you often end up with symbols partly overlapping each other. Of course, the symbols can be manually moved around after initial placement to get a more aesthetically pleasing result, but that can be a tedious and time-intensive task.
Thankfully, there is a way to automate at least part of this process by using MAPublisher and LabelPro.
This example shows the heart of an old European city (Breda in The Netherlands to be exact). The map is composed of Dutch Top10NL topographic base data, a few labels were manually added for larger features (such as the park), and points imported from OpenStreetMap (OSM) and styled using a Map Theme. As you can see, there are a number of spots where the symbols are densely located and overlap each other.
The MAPublisher LabelPro add-on is capable of collision-avoidance to make sure overlaps don’t happen. But it only works when generating labels (text). Fortunately, the solution is to trick LabelPro into processing symbols too, so that they can benefit from better placement without overlaps.
Let’s start by adding a column to the attributes to the OSM points layer and filling it with a default value, a capital O.
Thankfully, there is a way to automate at least part of this process by using MAPublisher and LabelPro.
Next, determine how big the symbols are. On the artboard, use the Type tool to place a capital O and adjust its size so that it’s about the same size as one of the point symbols. In this case, a 14 pt Futura Medium, shown here in red, seems to cover it well (your results might be different).
Futura is a good font in this case because the O is a perfect circle. Once you’ve determined the approximate font size to use, delete the O text as it won’t be needed anymore.
Next, set up the LabelPro labelling rules. Since there is already a layer with the manually placed labels and the symbols shouldn’t interfere with them, the manually placed labels will be designated as an obstacle layer. The symbols layer will be labelled with the attribute created earlier and the style set to the font and size that was just determined.
Setting the appropriate rules partly depends on personal preference but it’s important to specify that the placement prefers the center position (position 1 on the placement control). In other words: if there’s enough space for placement, the label doesn’t need to be moved or offset. Another important rule to configure is that font reduction should be turned off. All of the labels (eventually symbols) are going to be a fixed and similar size.
Also, another good practice is to specify a suppression layer. Any labels that can’t be placed with the rules set will be placed on the suppression layer. After placement, you can determine if any labels need to be adjusted manually.
Let’s label! Go ahead and label with these settings and afterward hide the original symbols layer and the suppression layer. The map is filled with O’s where the original symbols are located.
At first glance, this does not seem very useful, but closer inspection shows that the labels have retained the attributes of the original OSM point symbols.
This means that if they can be turned back into points, they will be able to be styled!
In order to turn them back into points, a text reference point needs to be created. In other words: a little dot on the text selection line, in the center of the O. This is a two-step process. First, select all the O’s on the artboard, open MAPublisher Text Utilities, and set the Action to Set text alignment and Alignment to Center. This action changes the alignment of the text without changing the actual position of the text (due to LabelPro labeling the text alignment is different based on where the label ended up in relation to the original point). This step takes care of the horizontal positioning.
The second step is to adjust vertical positioning. Vertical positioning is adjusted by moving all text up by a certain distance. Make sure all the O’s are selected, then use the (Adobe Illustrator) Move tool. In the Position group, set the Horizontal to 0 (no adjustment here since Text Utilities was used), set the Vertical to minus half the text size (font size in this example was 14 pt, so a vertical adjustment of -7 pt), and the Angle to 90 degrees.
For reference, this example is zoomed into a symbol that did not get displaced.
Next, these labels need to be turned into point symbols. There is a handy option in MAPublisher Text Utilities that can do that, but it places a point to the lower left of the text and the symbols need to use the center text reference point that was just created. Instead, with all of the O labels selected, open the MAP Attributes panel and export the attribute table to a text file. Make sure to specify the option Export All Attributes because there are two important hidden attributes needed to make this work: #MapX and #MapY, which are the coordinates of the text reference point.
Using MAPublisher Import, add the attributes text file that was just created to the map and make sure to appropriately specify #MapX and #MapY in the X and Y coordinate columns.
Since there is no projection information stored in the text file, you’ll need to specify that the coordinates are in the same system as the MAP View it’s coming from and you’ll need to add it to that MAP View upon import.
On the map, there is now a new point layer and because they still have all of their original attributes, the layer can simply be added to the MAP Theme to have all the point symbols reapplied to them instantly. Let’s admire the results:
If needed, repeat the last few steps for the suppressed labels as well (to a different file and different layer of course) to see what still needs to be done manually.
Drawing inspiration from this Safe software blog post we have developed an FME workflow that allows the user to update multiple MAPublisher templates with additional layers using two workspaces and a workspacerunner transformer.
The folder structure for the project follows one possible standard arrangement. A data folder contains the shapefile that is being added to the existing .ai files. An output folder gathers the intermediate .ffs files generated by FME that pass the data to MAPublisher. The templates folder contains the .ai files that will have the layer added to them. Finally the workspaces folder contains the two workspaces required for the transformation.
The runner workspace uses a path reader to get the filenames and paths of the .ai files. A filter is applied to make sure only files with the extension “.ai” are read. After the path reader an attribute creator adds the path for the output .ffs files as an attribute. This is dynamically calculated based on the filenames of the input .ai files.
The full paths to the template files and the paths to the output ffs files are passed as published parameters to the worker workspace. Two published parameters have been created in the worker workspace and linked to parameters in the MAPublisher writer. This allows the writer to take the values passed from the runner workspace. The worker workspace is run once for every file that is in the folder of ai files, and these published parameters update dynamically for each one.
The worker workspace has a shapefile reader that reads in the layer that is going to be added to each template. At this point multiple readers or other transformers could be added to increase the complexity of the transformation.
When the runner workspace is launched each template is opened up, the shapefile is read and added to a new MAPView in the MAPublisher document. Equally it could be added to an existing MAPView with a matching coordinate system. These documents can be left open as shown here, or with the addition of another published parameter new output .ai files could also be specified.
Creating multiple maps that share cartographic styling is a common requirement for MAPublisher users. The most effective way to accomplish this is the use of MAP Themes. MAP Themes are a collection of thematic cartography tools designed to increase productivity by automating how styles and symbols are applied. Creating a number of MAP Themes based on regularly used layers with standard attribute schemas can greatly reduce the amount of time spent styling maps.
This guide will walk through creating and setting up MAP Themes to automatically apply to the appropriate layers upon import. If done correctly, rather than seeing this:
You will see this when importing data to MAPublisher:
1. Data Source
The data used in this guide comes from the publically available CanVec+ topographic database. CanVec+ contains a comprehensive set of layers optimized for display at 1:50,000 that are perfect for topographic mapping. In fact, many of these layers are used in the construction of the CanTopo Topographic mapping series available here.
The layers you receive from the CanVec+ download service will vary depending on what features are present in the extent chosen. The Geogratis Geospatial Data Extraction tool is the most convenient method to retrieve CanVec+ data. This guide uses a selection of CanVec+ layers styled similarly to the CanTopo maps.
All vector data was downloaded in an unprojected geodetic coordinate system and projected into a UTM projection MAP View.
The map shown above contains 12 vector layers and one raster layer, but we will only discuss the styling and configuration of three layers as the process is similar for the rest. You can download the Adobe Illustrator file at the bottom of the page if you want to examine the different layers, their graphic styles and MAP Themes.
MAP Themes are the primary method for applying attribute based cartographic symbology. A powerful feature is the ability to automatically do this on layer import based on geometry type or file name. By defining one or many graphic styles and a MAP Theme for each layer the layers can be automatically styled on import.
CanVec+ themes have a consistent naming scheme that makes them especially suitable for this sort of automated styling. Because each style is always named the same, it is simple to set up the MAP Themes to automatically apply when the layers are imported. The theme names are consistent but somewhat obscure, as are some of the attribute names and values. Luckily there is a specifications document that provides a guide to the various themes, datasets and attributes that are available. A link is provided in the useful resources section below. While the style guide is helpful, it can be difficult to navigate, so it has also been translated into a more easily readable Excel spreadsheet, which also available in the useful resources.
A CanTopo symbology guide is available for download and was used to help define the styles for the different layers used in this map. A link is available in the useful resources section at the bottom. The University of Toronto also hosts an old specifications guide, but as it is almost 14 years old it should not be assumed to be accurate. If you are looking for inspiration though, it is useful.
2. Example A: Building point locations
2a. Building Point Symbol
The Graphic style for the building symbols is a black square rotated to match the value in an orientation attribute. Using the CanTopo symbology guide a correctly sized square was created and then added to the symbol library.
2b. MAP Theme
A new Point Stylesheet MAP Theme was created called Buildings. The appropriate layer “bs_2010009_0” was added to the Theme and a rule was created named “All” as it will apply to all the building point locations. The Rule Expression is set to apply the Theme to all artwork as we want all the building points to look the same.
The Visual Properties tab was used to determine how the buildings would appear. The Symbol property was set to use the Building black square symbol created and added to the Symbol library earlier. The Rotation property was set to use the “orientatio” attribute. This ensures the buildings are oriented correctly.
Finally, and most importantly for the MAP Theme automation, the Auto-assign option was set so that any layer that matches the filename of the imported shapefile would automatically be styled using this theme.
3. Example B: Contours
3a. Contours Graphic Style
Two Graphic styles were created for the contours: one for the regular contours and one for the index contours at intervals of 100m. Both are grey, with the index contours slightly thicker (although it is hard to tell in the Graphic Styles panel.)
3b. MAP Theme
A Line Stylesheet MAP Theme was created called Contours. The layer “fo_1030009_1” was assigned to the MAP Theme. Two rules were created, one for index contours and one for regular contours. For the index contours, the Advanced Rule Expression builder is used to select any contour where the elevation is a multiple of 100, and the converse for the regular contours.
The Modulo (MOD) function makes this simple. For the index contours, the expression built as: “MOD(elevation,100)=0”. For the regular contours, the expression is “MOD(elevation,100)!=0”. The != operator means not equal to.
The Modulo function will be available with a future release of MAPublisher. If you are using an earlier version of MAPublisher, the same result for index contours can be had with this expression:
(elevation/100)-ROUNDDOWN(elevation/100,0)=0
If you do try and apply this MAP Theme with an earlier version of MAPublisher without changing the equations, it will not work and you will get errors.
Each rule is assigned the appropriate graphic style applied in the Visual Properties. Creating Graphic Styles in advance is much easier than trying to remember specific stroke/colour combinations and makes them re-usable.
It is worthwhile organizing them in the Graphic Styles panel and naming the Graphic Styles appropriately so you can easily remember which is which later.
The layer is then set as auto-assigned so that when it is imported in the future this MAP Theme will automatically be applied.
4. Example C: Roads
4a. Graphic Style
The Roads layer is the most complex as there are multiple different classes of roads, that are then broken down into sealed and unsealed surfaces, and can be at grade, tunnels or bridges. Several of the road classes are assigned the same Graphic Style, so each style was named after a representative road class and assigned to several MAP Theme Rules.
4b. MAP Theme
There are defined styles of roads in the CanTopo specifications, but these do not map directly to the attributes that are present in the CanVec roads dataset. There are several attributes that hold information about the composition of the road, but the ones that were used to define the MAP Theme Rules were:
roadclass: a heirachy of road types
structype: defines if the road is a road, a bridge or a tunnels
pavstatus: contains information on the road surface, if it is paved or unpaved.
A Line Stylesheet Theme was created called Roads. The layer tr_1760009_1 was assigned to this Theme. Each road class has its own rule. The rule expression determine what class of road it is, if it is a bridge or a tunnel, and if it is paved or unpaved. An example of this is “Arterial: Paved: Bridge” with the expression:
roadclass=3 AND pavstatus=1 AND (structype =1 OR structype =2 OR structype =3 OR structype =4)
which simply says select art that is an Arterial Road (roadclass=3) is paved (pavstatus=1) and one of four different types of bridge (structype 1 through 4).
As in previous examples, each rule is assigned a Graphic Style in the Visual Properties tab.
The layer is set to auto apply on import.
Once rules are created and applied to all the imported layers the end result looks like this:
5. Hillshade
In addition to vector data, the GeoGratis portal has raster terrain data available for download. There are digital elevation models, digital surface models, and a variety of derived products such as slope and aspect. For this map we downloaded a hillshade and adjusted the opacity so it would blend with the map style. The forest cover layer and the built up areas layer also had their blending modes adjusted so the hillshade would show through.
The hillshade was downloaded in an unprojected geodetic coordinate system and Geographic Imager was used to transform it into the UTM projection used for this map.
6. Final words
In order for the defined MAP Themes to be automatically applied to any imported data, the imported layer filenames must match those defined in the MAP Theme Rules as discussed above. If you would like to try it out with your own CanVec data extract, do the following:
Download the “Canvec_Data_Themes.ai” file linked below for the version of Illustrator you are using. Have a look at the data structure, layer names and MAP View properties of this document.
Also download the appropriate “Canvec_Data_Themes_Empty.ai” file to use as a template.
Download an extract of CanVec data as shapefiles.
Use the Advanced Import functionality to import the shapefiles into the empty document. Reproject the map if desired.
The imported data have the styles applied automatically. However, you will probably have a few layers that have no style. Use the methods detailed above to create new styles for those layers.