
Tidy Tuesday: Fortresses date like palaces, not castles
Preface
From the TidyTuesday repository.
This week we’re exploring the Castlemap dataset of 5,793 castles, fortresses, palaces and ruins in 138 countries. The data comes from Wikidata, and every landmark has verified coordinates, a Wikipedia article and a photo on Wikimedia Commons. Each also has a fame rank, based on how many languages have an article on it and how often that article is read. The Great Wall of China is first.
Georgios Karamanis curated it. One of the suggested questions is whether palaces are newer than fortresses. They are, but only by about fifty years at the median, which is less interesting than what the question assumes. I expected fortresses to sit with castles as the “old, military” pile. Going by founding year, they sit with the palaces instead.
Loading necessary packages
Code
library(tidyverse)
library(tidytuesdayR)
library(skimr)
library(scales)
library(paletteer)
library(ggdist)
`%ni%` <- Negate(`%in%`)
delft <- as.character(paletteer::paletteer_d("dutchmasters::view_of_Delft"))
delft_sky <- delft[1]
delft_brick <- delft[6]
delft_brown <- delft[11]Load raw data from package
raw <- tidytuesdayR::tt_load("2026-09-01")
world_castles <- raw$world_castlesExploratory data analysis
I’m leaving out the IDs, names, and URLs, plus century, which is just year turned into text.
world_castles %>%
select(category, country, lat, lon, year, year_approx, sitelinks, pageviews, fame_rank) %>%
skim()| Name | Piped data |
| Number of rows | 5793 |
| Number of columns | 9 |
| _______________________ | |
| Column type frequency: | |
| character | 2 |
| numeric | 7 |
| ________________________ | |
| Group variables | None |
Variable type: character
| skim_variable | n_missing | complete_rate | min | max | empty | n_unique | whitespace |
|---|---|---|---|---|---|---|---|
| category | 0 | 1 | 4 | 8 | 0 | 4 | 0 |
| country | 0 | 1 | 4 | 32 | 0 | 138 | 0 |
Variable type: numeric
| skim_variable | n_missing | complete_rate | mean | sd | p0 | p25 | p50 | p75 | p100 | hist |
|---|---|---|---|---|---|---|---|---|---|---|
| lat | 0 | 1.00 | 41.88 | 14.73 | -53.63 | 37.18 | 46.17 | 50.51 | 81.72 | ▁▁▁▇▁ |
| lon | 0 | 1.00 | 23.48 | 43.92 | -175.20 | 3.56 | 14.40 | 28.98 | 174.79 | ▁▁▇▂▁ |
| year | 2183 | 0.62 | 1445.01 | 368.73 | -3000.00 | 1250.00 | 1500.00 | 1700.00 | 2009.00 | ▁▁▁▁▇ |
| year_approx | 0 | 1.00 | 0.09 | 0.28 | 0.00 | 0.00 | 0.00 | 0.00 | 1.00 | ▇▁▁▁▁ |
| sitelinks | 0 | 1.00 | 11.13 | 10.08 | 2.00 | 6.00 | 8.00 | 13.00 | 192.00 | ▇▁▁▁▁ |
| pageviews | 1 | 1.00 | 11719.36 | 42719.02 | 0.00 | 520.75 | 1969.00 | 7618.00 | 1441865.00 | ▇▁▁▁▁ |
| fame_rank | 0 | 1.00 | 2897.00 | 1672.44 | 1.00 | 1449.00 | 2897.00 | 4345.00 | 5793.00 | ▇▇▇▇▇ |
world_castles %>%
count(category, sort = TRUE)# A tibble: 4 × 2
category n
<chr> <int>
1 castle 2591
2 fortress 1180
3 ruin 1088
4 palace 934
world_castles %>%
group_by(category) %>%
summarise(
landmarks = n(),
dated = sum(!is.na(year)),
share_dated = dated / landmarks,
approx_years = sum(year_approx == 1 & !is.na(year))
)# A tibble: 4 × 5
category landmarks dated share_dated approx_years
<chr> <int> <int> <dbl> <int>
1 castle 2591 1453 0.561 257
2 fortress 1180 735 0.623 78
3 palace 934 718 0.769 72
4 ruin 1088 704 0.647 101
There are four categories, spelled exactly castle, fortress, palace and ruin. Castles make up almost half the file. The big gap is year. A bit under 40% of landmarks have no founding year at all, and castles are the worst covered: only 56% have one, against 77% for palaces. Some 508 rows are flagged as approximate.
The year range runs from -3000 to 2009. The far end of that range has some obvious problems:
world_castles %>%
filter(year > 2000) %>%
select(name, category, country, year, year_approx) %>%
arrange(year)# A tibble: 5 × 5
name category country year year_approx
<chr> <chr> <chr> <dbl> <dbl>
1 Forte Tre Sassi fortress Italy 2002 0
2 Putin's Palace palace Russia 2005 0
3 São Marcelo Fort fortress Brazil 2006 0
4 Citadel of Erbil fortress Iraq 2007 0
5 Bolaman Castle castle Turkey 2009 0
The Citadel of Erbil is a settlement mound that has been occupied for thousands of years, and it’s listed as founded in 2007. Wikidata’s founding date is sometimes a rebuild, a restoration, or the date a site got its current name. I’m not going to try to hand-correct 5,000 rows. Most of these oddities are a handful of points at the ends of the range, so they barely move medians or shares. Still, keep them in mind.
Splitting at 1500
The question I’m asking is simple: of the dated landmarks in each category, what share were founded before 1500 and what share in 1500 or later? 1500 is a round number, and it’s close to when artillery forts with low, angled bastions started replacing tall stone walls in Europe. I’m not testing that history here. I just picked a cut point that would mean something if the categories split around it.
category_order <- c("ruin", "castle", "fortress", "palace")
dated <- world_castles %>%
filter(!is.na(year)) %>%
mutate(category = factor(category, levels = category_order))
cat(sprintf("dated: %d rows, %d cols\n", nrow(dated), ncol(dated)))dated: 3610 rows, 15 cols
stopifnot("Plot data has 0 rows — check filter values" = nrow(dated) > 0)
era_split <- dated %>%
group_by(category) %>%
summarise(
dated = n(),
median_year = median(year),
share_1500_on = mean(year >= 1500),
share_before = 1 - share_1500_on
) %>%
left_join(count(world_castles, category, name = "landmarks"), by = c("category"))
era_split# A tibble: 4 × 6
category dated median_year share_1500_on share_before landmarks
<chr> <int> <dbl> <dbl> <dbl> <int>
1 ruin 704 1294. 0.199 0.801 1088
2 castle 1453 1350 0.344 0.656 2591
3 fortress 735 1667 0.8 0.2 1180
4 palace 718 1716 0.829 0.171 934
Fortresses and palaces are almost the same: 80% of dated fortresses and 83% of dated palaces were founded in 1500 or later. For castles it’s 34%. Ruins are even older, which makes sense. A lot of them are castles that fell down.
Two things could fake this result. Approximate years could bunch up on round centuries, and the fortress list is much more global than the castle list. Fortresses include colonial forts in the United States, Brazil, Ghana and Canada, and those can’t predate the 1500s. So I re-ran the split with exact years only, and then on a rough Europe box (longitude -11 to 40, latitude above 35). The box is crude, but it’s good enough for this check.
dated %>%
filter(category == "fortress", country %in% c("United States", "Brazil", "Ghana", "Canada")) %>%
group_by(country) %>%
summarise(fortresses = n(), earliest = min(year), median_year = median(year))# A tibble: 4 × 4
country fortresses earliest median_year
<chr> <int> <dbl> <dbl>
1 Brazil 23 1555 1700
2 Canada 19 1629 1751
3 Ghana 22 1515 1678.
4 United States 69 1564 1833
robustness <- bind_rows(
dated %>% mutate(subset = "all dated"),
dated %>% filter(year_approx == 0) %>% mutate(subset = "exact years only"),
dated %>% filter(between(lon, -11, 40), lat > 35) %>% mutate(subset = "rough Europe box")
) %>%
group_by(subset, category) %>%
summarise(share_1500_on = mean(year >= 1500), .groups = "drop") %>%
mutate(share_1500_on = percent(share_1500_on, accuracy = 1)) %>%
pivot_wider(names_from = category, values_from = share_1500_on)
robustness# A tibble: 3 × 5
subset ruin castle fortress palace
<chr> <chr> <chr> <chr> <chr>
1 all dated 20% 34% 80% 83%
2 exact years only 21% 36% 84% 86%
3 rough Europe box 13% 28% 75% 82%
Dropping approximate years changes almost nothing. Restricting to Europe makes everything a bit older, but castles drop the most, to about a quarter founded in 1500 or later. European fortresses are still three-quarters 1500-or-later. The colonial forts push the global fortress share up, but they aren’t the reason fortresses look young.
plot_years <- dated %>%
filter(year >= 1000) %>%
mutate(category = fct_rev(category))
cat(sprintf("plot_years: %d rows, %d cols\n", nrow(plot_years), ncol(plot_years)))plot_years: 3416 rows, 15 cols
stopifnot("Plot data has 0 rows — check filter values" = nrow(plot_years) > 0)
n_off_left <- nrow(dated) - nrow(plot_years)
row_labels <- era_split %>%
mutate(
label = sprintf("%s\n%s of %s dated", str_to_title(category), comma(dated), comma(landmarks))
) %>%
select(category, label) %>%
deframe()
share_labels <- era_split %>%
mutate(category = factor(category, levels = rev(category_order)))
p <- plot_years %>%
ggplot(aes(x = year, y = category)) +
annotate(
"rect",
xmin = 1500, xmax = 2010, ymin = -Inf, ymax = Inf,
fill = delft_sky, alpha = 0.08
) +
geom_vline(xintercept = 1500, color = "grey35", linewidth = 0.5, linetype = "22") +
annotate(
"text",
x = 1505, y = 4.95,
label = "1500",
hjust = 0, vjust = 1, size = 3.4, fontface = "bold", color = "grey30"
) +
stat_slab(
aes(fill = after_stat(x >= 1500)),
normalize = "groups",
height = 0.68,
color = NA,
adjust = 0.6
) +
stat_pointinterval(
point_interval = "median_qi",
.width = 0.5,
position = position_nudge(y = -0.25),
color = "grey20",
point_size = 2.2,
interval_size_range = c(0.8, 1.6)
) +
geom_text(
data = share_labels,
aes(x = 1010, y = category, label = paste0(percent(share_before, accuracy = 1), " before 1500")),
hjust = 0, vjust = 1.6, size = 3.5, color = delft_brick, fontface = "bold",
inherit.aes = FALSE
) +
geom_text(
data = share_labels,
aes(x = 2005, y = category, label = paste0(percent(share_1500_on, accuracy = 1), " in 1500 or later")),
hjust = 1, vjust = 1.6, size = 3.5, color = "grey25", fontface = "bold",
inherit.aes = FALSE
) +
scale_fill_manual(values = c(`FALSE` = delft_brick, `TRUE` = delft_sky), guide = "none") +
scale_y_discrete(labels = row_labels, expand = expansion(add = c(0.45, 0.9))) +
scale_x_continuous(
breaks = seq(1000, 2000, by = 100),
labels = function(x) if_else(x %% 200 == 0, as.character(x), ""),
expand = expansion(mult = c(0, 0))
) +
coord_cartesian(xlim = c(1000, 2010), clip = "off") +
labs(
title = "Fortresses date like palaces, not castles",
subtitle = sprintf(
"Founding years of %s dated landmarks in the Castlemap dataset. Dot and bar show the median and middle half.\n%d landmarks founded before 1000 are off the left edge but counted in the percentages.",
comma(nrow(dated)), n_off_left
),
x = "Founding year",
y = NULL,
caption = "Data: Castlemap (Wikidata) via TidyTuesday 2026-09-01. Founding years are as recorded in Wikidata; some are rebuild or restoration dates."
) +
theme_minimal(base_size = 12) +
theme(
plot.background = element_rect(fill = "#FBFAF7", color = NA),
panel.grid.minor = element_blank(),
panel.grid.major.y = element_blank(),
panel.grid.major.x = element_line(color = "grey88", linewidth = 0.3),
axis.text.y = element_text(color = "grey20", hjust = 0, lineheight = 1.1, size = 10.5),
axis.text.x = element_text(color = "grey35"),
axis.title.x = element_text(color = "grey40", size = 10, hjust = 0, margin = margin(t = 8)),
plot.title = element_text(face = "bold", size = 19, color = "grey15"),
plot.subtitle = element_text(color = "grey30", size = 10, lineheight = 1.15, margin = margin(b = 14)),
plot.caption = element_text(color = "grey45", hjust = 0, size = 8.5),
plot.title.position = "plot",
plot.caption.position = "plot",
plot.margin = margin(14, 18, 10, 10)
)
p
The castle and ruin ridges peak in the 1200s and 1300s. Ruins mostly stop at 1500. Castles have a second, smaller bump around 1600 and then fade out. The fortress ridge is almost flat through the medieval centuries, climbs in the 1500s, and stays high all the way to a peak in the 1800s. The palace ridge covers the same stretch, with more of its weight in the 1700s. If you only had the founding-year curve, you could tell a castle from a fortress much more easily than a fortress from a palace.
These categories come from how Wikidata classifies each item, not from an architectural survey. A medieval stronghold that someone tagged as a fortress counts as a fortress here, and one that was later turned into a palace may land in either pile. The split is between labels, and it’s only as clean as the labels are.
Final thoughts and takeaways
To answer the suggested question directly: yes, palaces are newer than fortresses, by about half a century at the median. The bigger gap is between fortresses and castles. Fortresses in this dataset are mostly an early modern thing. Castles are mostly medieval. Ruins are older still. That holds with exact years only, and it holds inside Europe, so it doesn’t come from rounded dates or from colonial forts.
The weak spot is the year column. Almost 40% of landmarks have no founding year, and castles are the least likely to have one. If the undated castles skew one way, older because nobody knows when they went up or newer because they’re minor 19th-century follies, the castle ridge would move. I’d guess older, but I can’t check that with this data. A few dates, like the Citadel of Erbil in 2007, are plainly rebuild dates rather than foundings.
If I came back to this, I’d look at the fame columns next. Do the 19th-century revival castles get read more than the medieval ones, Neuschwanstein-style? That’s the third suggested question in different clothes, and the data is already here.