Measuring Area in Illustrator to Scale

I’m building out a full wiki for The Embers, and one element in the Infobox I’ve been leaving blank is Area (square miles). Counting hexes and estimating seems laborious and ineffective, but there wasn’t a good way to measure the exact area of nations, baronies, tribal reaches, and free cities of Eilarûn.

Fewer red links each day, but those xxx,xxx haunted my dreams.

This might not be helpful to those who map in Photoshop, GIMP, etc., though Inkscape does have a feature similar to Illustrator’s Image Trace, so one could always export a large bitmap from whichever program and get SVG shapes that way.

Scroll to the bottom if you just want the code.

I knew that my hexes were 24 miles from center to center, or 12 miles from center to apothem, but I didn’t know the side length, which is, I think, the easiest way to calculate hexagon area:

A = (3 × √3 × s²) / 2

In Illustrator, Window > Document Info > Objects will give you the length of a path. So that solved side length, and I could calculate area. A side was 0.1419 inches. My hexes were 0.052314 inches square.

Now to figure out the ratio and get a scale factor.

I always try to check my math – a post on a 1e d&d forum (so you know they’re serious) gave me the area of a hexagon at certain dimensions.

I created a line that was 24 inches at 90° in Illustrator, Alt+Shift created a hexagon centered on the lower endpoint, and then Alt+Shift expanded the bounding box until the upper edge reached the midpoint.

My math from the side above matches the forum’s number. I now have my ratio (scale factor):

R = (hex area in miles) / (hex area in inches on map)

I found this code snippet on Github, which allows one to get the area of a shape in Illustrator, in in² and cm². Using the scale factor, I can calculate the area in mi² (because what self-respecting grimdark would use a logical system like metric?).

(shape area in miles) = R × (shape area in inches)

I’m already using a script; why not fork and modify for this specific use?

Adds/changes to bryanbuchanan‘s code:

  • I stripped out centimeters (that was a mistake; it would give more granularity – important when working at small scales – I will likely add back in)
  • Increased decimalPlaces to 10 (see: small scales)
  • Added the scale factor math above
  • Multiplied scale factor by areaIn
  • alert() box changes, including rounding off and a prettyprint with commas for mi² from here

You’ll need to adjust hexAreaInchesMap to the area of your map’s hexes. If you’re not using 24 mile hexes, you’ll also need to adjust hexAreaMileActual to the area your hexes represent.

If you’d like to fork, or follow as I update/expand on this (revert to cm, fix that km² isn’t really as exact as it should be, convert this to python for Inkscape, etc.), you can find my code on Github here.

Save as a .jsx file. In Illustrator, select the border outline of a nation, then run the script from File > Scripts.

Worldbuilding detail obsession made simple(r)!

Leave a Reply

Your email address will not be published. Required fields are marked *