The Assault on Copenhagen

Second Northern War, 1655-1660

Winter was coming. Denmark and Sweden had been at war for years, along with the Dutch, Russians, Prussians, Brandenburgs, Poles, and Lithuanians.

Battle of Lemke

Skirmish with Polish Tatars
Lemke, via Wikipedia

No love was lost between the two nations. A generation prior, Sweden had been part of the Danish Empire. But in June of 1657, with King Charles X of Sweden bogged down in Poland, Denmark attacked mainland Sweden and its outlying possessions to regain lost territory.

Assault on Copenhagen

king charles x

King Charles X Gustave of Sweden via Wikipedia

King Charles responded immediately. But rather than counterattacking Danish troops on the Swedish mainland, he withdrew from the years of battles in Poland and attacked westward from Swedish territory in Pomerania. His troops retook Bremen-Verden from the Danes and occupied the Danish mainland of Jutland within a month. As the Swedes seiged Danish forts that autumn, the Danes strategically withdrew to their island stronghold of Copenhagen for the winter, not expecting an attack until spring.

King Charles X’s advance on Copenhagen, 1657-58
Danish territory in red, Swedish territory in blue.
Yellow/blue stripes: Danish provinces lost in 1658 after the Treaty of Roskilde.
Red/blue stripes: Norwegian provinces lost by Denmark in 1658 but regained by 1860.
Click to occupy Copenhagen in full screen ➹

Unfortunately for the Danes, the winter was extraordinarily cold, and the straits between Jutland and the islands leading to Copenhagen froze over. On January 30 of 1658, King Charles X sent 12,000 soldiers marching over the frozen “Little Belt” with no losses. They then island-hopped over the “Big Belt”.

crossing the belts

Crossing of the Belts
by Lemke, via Wikipedia

By February 15, to the great surprise of the Danes, King Charles X and his Swedish troops were at the city walls of Copenhagen.

In a panic, Denmark signed a peace treaty on February 18, and by February 26, the Treaty of Roskilde where they gave up their remaining territory on the Swedish peninsula (the provinces of Scania, Halland, Bohusländ and Bleckinge). The Danish Empire was starting to fade.

Despite the treaty, King Charles attacked Denmark again in the summer of 1658, but the Dutch sent a fleet to provide supplies and assistance and defeated the Swedish navy within sight of Copenhagen (and the newly acquired Swedish coastline).

1659 fleets

Danish, Dutch and Swedish fleets, summer of 1658 via Wikipedia

But wait, there’s more. King Charles attacked Copenhagen yet AGAIN in February of 1659, but this time the Danes were prepared.

seige of copenhagen

Assault on Copenhagen (1659) during the 1658/59 siege
Frederik Christian Lund, via Wikipedia

They cut holes in the ice to prevent another military crossing, and the remaining Swedish troops were forced to pull back to the Danish mainland. That summer, Polish, Austrian and Brandeburger troops defeated the Swedish Army in Jutland and thousands of Swedish troops were taken prisoner.

King Charles X died in February of 1660. Soon after, Denmark and Sweden signed the Treaty of Copenhagen, “formalizing” the borders between Denmark, Sweden and Norway.

FORESHADOWING: Denmark was able to keep the island of Bornholm in exchange for giving up territory in southern Sweden.


In April 2016, the Pelias Geocoder team at Mapzen had just pushed a major update with vast improvements in both the code and the data.


Everything looked good until reports suddenly started coming in: According to users of Mapzen Search, Copenhagen was part of… Sweden! Had King Charles X finally occupied Copenhagen three and a half centuries later?


International tensions were high, and the Pelias and Who’s On First teams raced to diagnose the problem.

winter is coming

Like any geocoder, Pelias has to be concerned with not just where places are but what other places they belong to. We quickly determined that the region of Denmark surrounding Copenhagen, known as Hovedstaden, was also being reported as part of Sweden.

Hovedstaden (which basically means capital city area) has an unusual shape. It consists of the area immediately around Copenhagen, as one expects, but also an island far to the east — wait for it… BORNHOLM.


Directly in between Copenhagen and Bornholm? The southern tip of Sweden, once known as Scania, which once was part of… Denmark.

The country parentage of Hovedstaden was originally calculated in our data by determining the “centroid” of Hovedstaden, and determining which country that point was in.

But which centroid? That’s an interesting question. In Who’s On First, we generate multiple centroids for places. The geom centroid is effectively the geographic center, generated using Sean Gilles’ Shapley. The lbl centroid, is more of like a… center of mass. It’s a spot where you’d probably want to put a label, and is generated using Matthew Block’s Mapshaper. Taking a look at the map of Hovedstaden, the big pink dot on the map above is the lbl centroid, and the little orange dot is the geom centroid… (See also San Francisco for another troublesome island centroid issue.)

While we fixed the parentage of Hovedstaden, the Pelias team members are students of history and have battled bugs before and we knew there was more to do. We wrote a solid test case for Copenhagen and all the world’s capital cities. Also, Who’s on First can now detect when other countries breach bounding boxes (as indicated by the yellow dotted line and hover-over warning in the Hovedstaden map). And we have tools for reversegeo centroids, a.k.a. point-in-polygon.

These changes, like the city walls of old, will hopefully keep King Charles out of Copenhagen.