← AgenticGHX · Learn
AgenticGHX · Learn · Explainer

When vector stops winning

Every tutorial says the same thing: vector graphics are small, and they scale forever. Both halves are true right up until they aren't. Here is a scatter plot where the vector file is bigger than the raster — and where adding more data makes the raster file smaller. One rule explains that, a flag, and a 27 MB map of Ghana's districts.

Lesson progress 0%
0

Three pictures, one question

Every picture on every screen is one of two things. A raster is a grid of coloured dots. A vector is a list of instructions for drawing shapes. Most advice stops at "use vector when you can", which is where the interesting part starts.

Here are three real pictures. For each one, guess which version is the smaller file — the vector, or a good-quality raster of the same thing. Commit before you scroll; the answers are worth more if you have something to be wrong about.

Pick one for each.
1

Raster: a grid of numbers

A raster file stores a rectangle of dots. Ghana's flag as a image is — and that file knows nothing about flags, stripes or stars. It knows the colour of each of its dots and nothing else.

Two consequences follow immediately, and they are the whole of raster behaviour. The size of the file depends on how many dots there are — the width times the height — and on how hard those dots are to compress. And the picture has a native size: display it bigger than it was stored and something has to invent the dots in between.

If you want this taken apart properly — a pixel you can click, what a filter really does, why JPEG damage compounds when you re-save — that is a different lesson: one flyer, two kinds of image pulls a single file to pieces. This page assumes it and goes after the choice instead.
2

Vector: a list of instructions

A vector file stores what to draw. Here is the entire Ghana flag — the real file this page uses, not a simplification of it:

loading…
drawing instructions: three stripes and a star
the whole file, gzipped as a web server would send it
any
size it can be drawn at, from the same bytes

Nothing in there is a dot. rect means "fill this rectangle", polygon means "join these corners". Ask for the flag at 60 pixels or at 6 metres and the same four instructions are re-executed at that size. The file does not know what size it is, which is exactly why it never blurs.

And the cost follows just as directly: a vector file's size depends on how many things it has to describe. Four shapes is four shapes. Six hundred thousand shapes is a different story, and that is the rest of this page.

3

The rule

Those two paragraphs are the whole thing. Put side by side, they predict every result on this page:

area × detail
Raster cost. How many dots, and how hard they are to compress. It does not care how many things are in the picture.
number of things
Vector cost. How many shapes, corners and instructions. It does not care what size you display it at.

Neither one scales with the other's variable. That is why the answer flips: a picture with few things is cheap as vector at any size, and a picture with very many things is cheap as raster at any complexity. Somewhere between the two, the curves cross.

The next three sections are that rule under test — once where vector wins enormously, once where the two cross, and once where raster wins by more than an order of magnitude.

4

Few things: the logo

The flag has four shapes, so the rule predicts vector wins, and wins by more the bigger you go. Drag the slider: both panels are the same flag, but the right-hand one is a raster being stretched.

Ghana flag drawn from the SVG instructions
Vector — re-drawn at whatever size you ask for
Ghana flag as a small raster image, stretched
Raster

5

Many things: the chart

Now the same drawing, over and over, with only one thing changing: how many points are in it. Same figure size, same dots, same everything else. Every marker is one more instruction the vector file has to write down, and not one more dot for the raster to store.

Drag through the sweep. The vector line climbs forever; the raster line climbs, flattens, and then comes back down.

SVG, gzipped PDF PNG at the crossover

6

Very many things: the map

Ghana's districts, as published by geoBoundaries. Every wiggle of every boundary is stored as a corner, and there are of them — about bytes each. That is a vector file of , or gzipped. The same map drawn as a -pixel picture is .

The raster is smaller, and this is the rule working exactly as advertised: 661,763 things is a lot of things, and the number of dots never changed.

Now watch what happens when you throw corners away. Drag the slider — the left panel is the rendered map, the bars are the two file sizes:

Ghana district boundaries at the selected level of simplification
of the original corners kept
of the pixels changed against the full-detail render

7

Four things people say about this

Each of these is repeated constantly, each is half right, and each has a number on this page that kills it.

8

What to send, and to whom

The rule turns into a decision you can make in about four seconds: count the things in your picture.

Two habits worth more than any format choice. Keep the file the thing was made in — the spreadsheet, the plotting script, the design file — because every export is disposable and that original is not. And export per destination rather than looking for one file that suits all of them; the projector, the journal and the WhatsApp group want three different things, and only one of them is your problem at a time.
9

Where I was wrong

Both of these were live in the measurement before the page was written, and both pointed the way I already expected — which is exactly why they took a while to catch.

The general lesson, and it is the useful one: a comparison that flatters the answer you already hold is the last one you will check. Both mistakes here made the story better — a 66× gap is a more exciting headline than 7.3×, and "you can see simplification in the file size" is a tidier rule than "you have to look at the pixels". Neither survived being measured properly.

Check your understanding

Five questions across the key ideas.
The lesson at a glance
✓ Measured, not estimated

Where these numbers come from

Every figure was computed by website/scripts/build-rastervector-data.py, offline, and written into this page as data. One drawing is exported as a vector master and then rasterised from it, so the vector and raster rows describe literally the same picture rather than two pictures that resemble each other. Every file-size comparison is gzipped on both sides. Library versions are recorded in the data blob, because byte counts depend on them. Built .

    Same discipline, different question

    Where this sits: the companion to this page is one flyer, two kinds of image, which takes a single file apart instead of choosing between three. If a word here was new, the glossary has it in plain English.

    This is one of the interactive explainers we make at AgenticGHX — talks, learning tracks, and research out of Ghana.

    More from AgenticGHX Learn →