/Vectorized-Mapmaking-Workflow

Using map data from Natural Earth, I created a vector image file of the world in which each country has been isolated. Moreover, I developed a way to automate the vector consolidation process.

Primary LanguageJavaScriptMIT LicenseMIT

Vectorized-Mapmaking-Workflow

Using map data from Natural Earth, my goal is to generate a World Map in the form of vector image file where vector elements (i.e. paths and fills) have been consolidated by country.

What Have I Done So Far?

I developed a way to automate the vector consolidation process.

The Showcase Commit

To kick off this repository, I included everything required to showcase the intended result of this workflow.

This commit includes a PDF file, a Javascript file, and a text file:

  • PDF File (Maps/_MercatorMapOutput.pdf): A Mercator projection map, composing thousands of unlabeled vector elements (strokes and fill paths) that aren't easily associated with countries.
  • Javascript File (Scripts/_consolidateCountries.js): A script that manipulates a given PDF file to clean up, consolidate, and label its vector elements.
  • Text File (Scripts/_Countries (Ordered).txt): A list of countries, ordered alphabetically.

I didn't include a "consolidated" map PDF; using the files I've provided, this can be generated by anybody using Adobe Illustrator.

How Do I Use These Files?

  1. Open the map file in Adobe Illustrator;
  2. Go to File > Scripts > Other Scripts. When prompted, select the _consolidateCountries.js file.
  3. When prompted again, select the _Countries (Ordered).txt file.

Workflow Components

This workflow can be separated into two parts:

  1. Generating a vector composition from map data.
  2. Consolidate the image file's vector elements.

The 1st step is detailed in the rest of this section.

1.0 — Select Map Data From Natural Earth

"Natural Earth is a public domain map dataset available at 1:10m, 1:50m, and 1:110 million scales."

On the Downloads page, you can download any map set.

During development, I opted to use the 1:10m Cultural Vectors dataset.

  • I hit the Download countries button on the Admin 0 — Countries section.

1.1 — Open Map Data in GQIS

In this part, you're translating the map data into something you can work with.

As simple as that sounds, this part of the process is the most involved you'll be if you want to generate your own map projections.

Pre-Reqs

First, you'll have to download GQIS.

  • During development, I chose the long term release (LTR), GQIS macOS Installer Version 3.22.

Next, make sure you have the map data ready: there'll be a .shp file in the dataset you downloaded.

  • During development, the name of the file I used was ne_10m_admin_0_countries.shp.

Beginning GQIS Sub-Workflow

  1. Open GQIS.
  2. Create New Project.
  3. Go to Layer > Data Source Manager.
    1. Select the Vector tab.
    2. In the Source Type section, select File.
    3. In the Source section under Vector Datasets, hit the open file dialog; select the .shp file from the dataset you downloaded.
    4. Confirm.
  4. Hit the Add button.

You should be seeing a monochromatic world map with borders.

1.2 — Prepare for Vector Image Generation

GQIS doesn't have a process for exporting consolidated vector images. It does, however, allow you to export the map as is to PDF, which gives you thousands of disparate vector elements.

A single vector element could represent anything from a small island to the mainland of a continent... On this map, the Phillipines consists of 97 vector elements.

With that in mind, the challenge is to export a vector composition in which the thousands of elements can be grouped into their respective countries. After the previous step, we're left with a monochromatic world map... there's no way to differentiate between vector elements if they're all the same color.

So for this step, you're going to apply a unique color to each country.

Using "Symbology" in GQIS: Part 1 (Setting Up)

When you imported the map data into GQIS, a new layer was generated (and it should already be selected).

  1. Go to Layers > Layer Properties.
  2. Select the Symbology tab.
  3. In the drop-down menu at the top of the Symbology panel, switch from Single Symbol to Categorized.
  4. In the Value drop-down menu, select GEOUNIT.

    In GQIS, this is an attribute associated with each country distinct from colonial or vassal influence; for example, the United States of America and the United States Virgin Islands are considered separate entities under this attribute.

  5. In the Color Ramp drop-down menu, select Color Ramp.
    1. The Color Ramp Type pop-up should have a drop-down menu with Gradient selected. Hit OK.

Using "Symbology" in GQIS: Part 2 (The Pigeonhole Principle)

I applied the Pigeonhole Principle to the process of assigning colors to countries:

  • Using the GEOUNIT attribute (on the 1:10m Cultural Vectors dataset) means that I assigned colors to 258 countries.
  • A color's hue can be represented by any number between 0—359.

Since there are fewer countries than hues, each country's color will be unique. This'll be important when we're checking colors later.

  1. On the Color Gradient pop-up that should be open after the previous step:
    1. Make sure the Type drop-down is set to Continuous.
  2. Select Color 1.
    1. Set HSV values to 0º, 100%, 100%.
  3. Select Color 2.
    1. Set HSV values to 359º, 100%, 100%.
  4. Double-click the gradient bar to add a Gradient Stop; do this 5 times.
  5. Separate each gradient stop by ~16.67%. Assign each gradient stop the following values:
Color Stop # Color Relative Position HUE (H) SAT (S) VALUE (V)
1Red 0.0 % 100% 100%
2Yellow 16.7 % 60º
3Green 33.3 % 120º
4Teal 50.0 % 180º
5Blue 66.7 % 240º
6Violet 83.3 % 300º
7Red (Off) 100.0 % 359º
  1. Hit OK.
  2. At the bottom of the Symbology panel:
    1. Hit the Classify button;
    2. Hit the Apply button;
    3. Hit OK.

You should have a colorized world map.

1.3 — Generate Vector Image of World Map

  1. Go to Project > Import/Export.
    1. Select Save Map as PDF.
  2. In the pop-up dialog, hit the Save button.
    1. OPTIONAL: You can change the resolution for a more precise SVG.
    2. OPTIONAL: You can uncheck the Simplify geometries to reduce output file size option in Advanced Settings.

You should have a PDF file containing the vector composition.

2.0 — Consolidate Vector Elements

Refer to the "How Do I Use These Files" sub-section near the beginning of this article.


Potential Applications

Motion Graphics. From the get-go, I envisioned being able to create cool travel transitions.

Picture this: You're a vlogger who believes you need to travel to find yourself.

Instead of a simple cut from a shot of you getting on a plane in America to a shot of you getting in a hack cab in Belarus, you could fade in and out of a smooth map transition that reminds you of the way Google Earth goes from place to place.

And you wouldn't have to worry about licensing fees!

Open-Source Map Graphics. From the get-go, I envisioned not having to pay for map graphics I could easily make myself.

Even the free options leave something to be desired. Sure, you could download a world map vector image, but the vector information would likely be limited. In any case, free or not, there's a major opportunity in being able to generate your own maps at will, projected however you want, and with as much detail as you want.

Future

The scope of this README may necessitate separating steps of the workflow from the reasoning behind them, or at the very least, having two versions of the README (minimalist vs. in-depth).

I'd like to expand the scope of this project to account for:

  • The multitude of map variants available in Natural Earth;
  • The multitude of projections available in GQIS.
  • Automation of post-workflow applications