How To Color Lines in Maps
Published: Mon, 11 Sep 2023
How to create SVGs from maps with several colors
It’s not unusual to find a map which has an additional line or lines in color showing the route of a journey. We want to preserve this color in the final SVG of the map we include with the book. We will use as an example a map reproduced in “Through the Brazilian Wilderness” by Theodore Roosevelt
-
Finding the best quality source scan
You always want to start with the very best scan of the image you can locate. Here's a JPG of the scan from “Through the Brazilian Wilderness”:
As you can see, there is a red line showing the journey, and an accompanying legend.
-
Process with a suitable bitmap editor
I use an editor for macOS called Acorn, but most other graphic editors would be suitable. The essential requirement is for it to have a function which will let you replace one color with another, and that it support multiple layers.
Open the source file in your editor and immediately duplicate the image layer. If you can rename the layers, call one of them “red-layer” and the other “black-layer”.
We are going to use the Replace Color function to replace the colors we don’t want in each layer. See this initial image which shows just a small portion of the map, with the two layers we’ve created.
Lock and hide “red-layer” and work on “black-layer”. Now apply the Replace Color to replace red with the background color. In the image below I’ve decreased the tolerance just enough to show you what I’m doing. You will want to increase the tolerance until the red is no longer visible at all.
Now work on “red-layer” and do the opposite: replace color to remove the black lines.
Tip: it’s a good idea to retain some “anchor points” at the corners of your image, the same location in each layer, so that when you vectorize, each vector will be of the same outside dimensions. The four corners of the maps would be good for this.
When that’s done to your satisfaction, export each layer separately as a JPG or PNG image, with a suitable name.
-
Vectorize the images
I use a program called simply “Image Vectorizer” for macOS, but Inkscape would be fine for this.
Use the program to vectorize each layer image separately. Save the SVG output as appropriately-named files, say “red-layer.svg” and “black-layer.svg”.
-
Import the SVGs into vector editor and color one layer
I use Affinity Designer for this, but I imagine that any good vector-based editor should work.
Import each SVG onto its own layer, and position each layer carefully so they overlap exactly. Then open up “red-layer” and apply color to all of the components. If necessary, you can then edit out the anchor points you placed at the corners of each layer.
Now export the combined image as a single SVG file, and apply the various SVG optimizations we prefer.
-
That’s it, you’re done!