topojson = require("topojson-client@3")
world = fetch("https://cdn.jsdelivr.net/npm/world-atlas@2/land-110m.json").then(r => r.json())
land = topojson.feature(world, world.objects.land)
// Palette and type
accent = "#C8102E" // averages, trails and stop rings
placeColor = "#1B6E80" // filming locations
elsewhereColor = "#D4930D" // locations outside North America and Europe
ink = "#1E1E1E"
paper = "#ECEEF0"
graphite = "#4A4E53"
mono = "'IBM Plex Mono', monospace"
size = Math.min(width || 800, 860)
home = [-40, 50]
moveMs = 1400
proj = d3.geoOrthographic()
.rotate([-home[0], -home[1]])
.fitExtent([[10, 10], [size - 10, size - 10]], {type: "Sphere"})
geoPath = d3.geoPath(proj)
places = transpose(places_data)
cents = transpose(centroid_data)
decs = transpose(decade_data)
tops = transpose(top_data)
stopsById = new Map(transpose(stop_data).map(s => [s.id, s]))
// One entry per trigger in the section, in document order
steps = [
{kind: "title"},
{kind: "intro"},
{kind: "period", period: 1},
{kind: "stop", period: 1, stop: "baku"},
{kind: "period", period: 2},
{kind: "period", period: 3},
{kind: "period", period: 4},
{kind: "period", period: 5},
{kind: "stop", period: 5, stop: "hong_kong"},
{kind: "stop", period: 5, stop: "ooty"},
{kind: "period", period: 6},
{kind: "stop", period: 6, stop: "sydney"},
{kind: "period", period: 7},
{kind: "stop", period: 7, stop: "wadi_rum"},
{kind: "stop", period: 7, stop: "istanbul"},
{kind: "decades"},
{kind: "elsewhere", center: [50, 20]},
{kind: "end"}
]
step = steps[Math.min(crTriggerIndex ?? 0, steps.length - 1)]
period = step.period ?? null
stop = step.stop ? stopsById.get(step.stop) : null
// State kept across steps: where the moving average sits, and the running comet
view = ({pos: null, comet: null})
lonLat = d => [d.lon, d.lat]
line = coordinates => geoPath({type: "LineString", coordinates})
targetOf = s => s.center ?? (s.stop ? lonLat(stopsById.get(s.stop)) : home)
radius = d3.scaleSqrt().domain([1, d3.max(places, d => d.n)]).range([2, 12])
front = d => {
const [lambda, phi] = proj.rotate()
return d3.geoDistance(lonLat(d), [-lambda, -phi]) < Math.PI / 2
}
// Move marks to their projected position and hide those on the far side
pin = sel => sel
.attr("transform", d => `translate(${proj(lonLat(d))})`)
.attr("display", d => front(d) ? null : "none")
// Map labels in monospace with a paper halo
halo = sel => sel
.attr("font-family", mono).attr("fill", ink)
.attr("paint-order", "stroke").attr("stroke", paper).attr("stroke-width", 3)
mapSvg = {
const svg = d3.create("svg").attr("width", size).attr("height", size).style("display", "block")
const defs = svg.append("defs")
// Pencil wobble: strong on the base map, light on trails and rings
const wobble = (id, scale) => {
const f = defs.append("filter").attr("id", id)
.attr("x", "-5%").attr("y", "-5%").attr("width", "110%").attr("height", "110%")
f.append("feTurbulence").attr("type", "fractalNoise").attr("baseFrequency", 0.03).attr("numOctaves", 2).attr("seed", 1)
f.append("feDisplacementMap").attr("in", "SourceGraphic").attr("scale", scale)
}
wobble("boil", 9)
wobble("sketch", 3)
// Diagonal pencil hatching for land
defs.append("pattern").attr("id", "hatch").attr("width", 5).attr("height", 5)
.attr("patternUnits", "userSpaceOnUse").attr("patternTransform", "rotate(40)")
.append("line").attr("x2", 0).attr("y2", 5)
.attr("stroke", graphite).attr("stroke-width", 0.9).attr("stroke-opacity", 0.55)
const base = svg.append("g").attr("filter", "url(#boil)")
base.append("path").attr("class", "geo").datum({type: "Sphere"})
.attr("fill", paper).attr("stroke", graphite).attr("stroke-width", 1.4)
base.append("path").attr("class", "geo").datum(d3.geoGraticule10())
.attr("fill", "none").attr("stroke", graphite).attr("stroke-width", 0.4).attr("stroke-opacity", 0.35)
base.append("path").attr("class", "geo").datum(land)
.attr("fill", "url(#hatch)").attr("stroke", graphite).attr("stroke-width", 1)
// Layers, bottom to top
svg.append("g").attr("class", "places")
svg.append("path").attr("class", "trail").attr("filter", "url(#sketch)")
.attr("fill", "none").attr("stroke", accent).attr("stroke-width", 2).attr("stroke-linecap", "round")
svg.append("path").attr("class", "dec-trail").attr("filter", "url(#sketch)")
.attr("fill", "none").attr("stroke", accent).attr("stroke-width", 1.5).attr("stroke-linecap", "round")
svg.append("g").attr("class", "comet").attr("filter", "url(#sketch)")
svg.append("g").attr("class", "decs")
svg.append("g").attr("class", "cents")
svg.append("g").attr("class", "stops")
return svg.node()
}
// Line boil: a new noise seed every 300 ms
_boil = {
const turb = d3.select(mapSvg).selectAll("feTurbulence")
const timer = d3.interval(() => turb.attr("seed", () => 1 + Math.floor(Math.random() * 1000)), 300)
invalidation.then(() => timer.stop())
}
// Filming locations change with the step only
_places = {
const kind = step.kind
const shown = kind === "intro" ? places
: kind === "elsewhere" ? places.filter(d => d.other)
: period ? places.filter(d => d.period === period) : []
d3.select(mapSvg).select(".places").selectAll("circle")
.data(shown, d => `${d.period}|${d.location_id}`)
.join(
enter => enter.append("circle")
.attr("r", 0).attr("fill-opacity", 0.6)
.call(e => e.transition().duration(500).attr("r", d => radius(d.n))),
update => update,
exit => exit.call(e => e.transition().duration(300).attr("r", 0).remove())
)
.attr("fill", kind === "elsewhere" ? elsewhereColor : placeColor)
.call(pin)
}
// Each step turns the globe and slides the average over moveMs, whatever the scroll speed
_view = {
const svg = d3.select(mapSvg)
const trail = svg.select("path.trail")
const done = step.kind === "end"
const p = done ? cents.length : (period ?? 0)
const past = cents.filter(c => c.period < p)
const goal = p >= 1 ? lonLat(cents[p - 1]) : null
const from = view.pos ?? goal
const posAt = from && goal ? d3.geoInterpolate(from, goal) : () => goal
// Turn the shorter way round
const r0 = proj.rotate().slice(0, 2)
const to = targetOf(step)
const r1 = [r0[0] + ((((-to[0] - r0[0]) % 360) + 540) % 360) - 180, -to[1]]
const rotAt = d3.interpolate(r0, r1)
const draw = k => {
proj.rotate(rotAt(k))
svg.selectAll("path.geo").attr("d", geoPath)
svg.selectAll(".places circle").call(pin)
const pos = view.pos = posAt(k)
trail.attr("d", pos ? line([...past.map(lonLat), pos]) : null)
// Period averages: past ones small, the current one large and labelled
const marks = [
...past.map(c => ({...c, current: false})),
...(pos ? [{...cents[p - 1], lon: pos[0], lat: pos[1], current: !done}] : [])
]
svg.select(".cents").selectAll("g.cent")
.data(marks, d => d.period)
.join(enter => {
const g = enter.append("g").attr("class", "cent")
g.append("circle").attr("stroke", accent).attr("stroke-width", 1.5)
g.append("text").attr("x", 12).attr("y", 4).call(halo)
return g
})
.call(pin)
.each(function(d) {
const g = d3.select(this)
g.select("circle").attr("r", d.current ? 8 : 4).attr("fill", d.current ? accent : paper)
g.select("text")
.text(d.current || done ? d.label : "")
.attr("font-size", d.current ? 15 : 11)
.attr("font-weight", d.current ? 600 : 400)
})
// Decade averages, drawn one after another
const shownDecs = step.kind === "decades" ? decs.slice(0, Math.ceil(k * decs.length)) : []
const labelled = new Set([1900, 1910, 1960, 1990, 2020])
svg.select("path.dec-trail").attr("d", shownDecs.length > 1 ? line(shownDecs.map(lonLat)) : null)
svg.select(".decs").selectAll("g.dec")
.data(shownDecs, d => d.decade)
.join(enter => {
const g = enter.append("g").attr("class", "dec")
g.append("circle").attr("r", 3.5).attr("fill", paper).attr("stroke", accent).attr("stroke-width", 1.2)
g.append("text")
.text(d => labelled.has(d.decade) ? `${d.decade}s` : "")
.attr("x", 8).attr("y", 4).attr("font-size", 12).call(halo)
return g
})
.call(pin)
// Stop ring fades in as the globe arrives
svg.select(".stops").selectAll("g.stop")
.data(stop ? [stop] : [], d => d.id)
.join(enter => {
const g = enter.append("g").attr("class", "stop")
g.append("circle").attr("r", 15).attr("fill", "none")
.attr("stroke", accent).attr("stroke-width", 2.2).attr("filter", "url(#sketch)")
g.append("text").text(d => d.name)
.attr("x", 20).attr("y", 5).attr("font-size", 15).attr("font-weight", 600).call(halo)
return g
})
.call(pin)
.attr("opacity", k)
}
// Clear the comet from the final step
view.comet?.stop()
svg.select(".comet").selectAll("path").remove()
svg.select(".cents").selectAll("g.cent").attr("opacity", null)
trail.attr("stroke-opacity", null)
svg.interrupt("move")
draw(0)
const move = svg.transition("move").duration(moveMs).ease(d3.easeCubicInOut).tween("move", () => draw)
// Final step: a comet runs along the dimmed trail at a steady speed and repeats.
// Ten stacked dashes of growing length end at the head, so overlap is densest there.
if (done) move.on("end", () => {
const len = trail.node().getTotalLength()
const tail = len * 0.35
const dur = 7000
const pause = 900
trail.attr("stroke-opacity", 0.25)
const comet = svg.select(".comet").selectAll("path")
.data(d3.range(1, 11).map(i => i / 10))
.join("path")
.attr("d", trail.attr("d"))
.attr("fill", "none").attr("stroke", accent).attr("stroke-width", 3)
.attr("stroke-linecap", "round").attr("stroke-opacity", 0.2)
.attr("stroke-dasharray", f => `${tail * f} ${len + tail}`)
// Distance along the trail to each period's average, measured on prefixes of the same line
const pts = cents.map(lonLat)
const probe = svg.append("path")
const at = pts.map((_, i) => i === 0 ? 0 : probe.attr("d", line(pts.slice(0, i + 1))).node().getTotalLength())
probe.remove()
// Each period lights up as the head reaches it and fades with the tail
const marks = svg.select(".cents").selectAll("g.cent")
const glow = k => k < 0 || k > tail ? 0.25 : 1 - 0.75 * k / tail
view.comet = d3.timer(elapsed => {
const head = Math.min((elapsed % (dur + pause)) / dur, 1) * (len + tail)
comet.attr("stroke-dashoffset", f => tail * f - head)
marks.attr("opacity", d => glow(head - at[d.period - 1]))
})
})
}
// Top five places for the current period, in a fixed panel at the lower right
topPanel = {
const el = htl.html`<div class="top-panel" aria-live="polite"></div>`
document.body.appendChild(el)
invalidation.then(() => el.remove())
return {el}
}
_top = {
const el = topPanel.el
if (!period) return el.classList.remove("show")
const rows = tops.filter(d => d.period === period)
const max = d3.max(rows, d => d.n)
el.replaceChildren(
htl.html`<div class="tp-title">Most titles ▸ ${cents[period - 1].label}</div>`,
...rows.map(d => htl.html`<div class="tp-row">
<span class="tp-name">${d.name}</span>
<span><span class="tp-bar" style="width: ${100 * d.n / max}%; background: ${d.other ? elsewhereColor : placeColor}"></span></span>
<span class="tp-n">${d.n.toLocaleString("en-US")}</span>
</div>`)
)
el.classList.add("show")
}
// Display the map
chart = mapSvgThe center of film
The
center
of
filmFollowing the average filming location since 1887Scroll, or use the arrow keys
Wikidata knows where 12,099 movies and TV shows were filmed.
01 ▸ Before 1920 ▸ 147 titlesSelznick Studio, Fort Lee, 1920. Public domainThe red dot is the average of each period’s locations, measured on the globe.Fort Lee, New Jersey, just across the Hudson, beats New York. Hollywood comes later.
Stop ▸ Baku, AzerbaijanStill from The Oil Gush in Balakhany (1898), Alexandre Michon. Public domainNowhere outside North America and Europe has more early films. Two of its 7, both from 1898, show oil gushers.
02 ▸ 1920–1945 ▸ 269 titlesHollywood studios from the air, 1922. Public domainLos Angeles takes over. Studios near London and in Berlin pull the average north-east, over Greenland.
03 ▸ 1946–1959 ▸ 489 titlesPinewood Studios. Photo: Shazz, CC BY-SA 2.0Pinewood Studios, west of London, beats every city.
04 ▸ 1960–1975 ▸ 1,123 titlesA set on the Pinewood back lot. Photo: Alexander P Kapp, CC BY-SA 2.0Pinewood, home of the early Bond films, still leads.The average reaches its easternmost point, just north of Ireland.
05 ▸ 1976–1999 ▸ 2,748 titlesQueensboro Bridge, New York, 1974. Photo: Danny Lyon, Documerica. Public domainLos Angeles and New York lead again, and the average moves back west.
Stop ▸ Hong KongPhoto: Mustang Joe, CC0Police Story, Chungking Express and 97 more.
Stop ▸ Ooty, IndiaPhoto: Hemant meena, CC BY-SA 3.0A hill station in Tamil Nadu, and a favorite of Indian cinema. Roja and Kuch Kuch Hota Hai were both shot here.
06 ▸ 2000–2012 ▸ 3,565 titlesLos Angeles from the Hollywood Hills. Photo: Blake Everett, CC0Los Angeles still leads, and the average barely moves.
Stop ▸ Sydney, AustraliaPhoto: W. Bulach, CC BY-SA 4.0Two Star Wars prequels and both Matrix sequels were shot here.
07 ▸ 2013– ▸ 3,758 titlesDowntown Los Angeles. Photo: Sevan Seviant, CC BY 3.0The average moves east again, to a point south of Iceland. Los Angeles is still on top.
Stop ▸ Wadi Rum, JordanPhoto: Raya Sharbain, CC BY-SA 4.0The desert stood in for Mars in The Martian and for Arrakis in Dune.
Stop ▸ Istanbul, TurkeyPhoto: Hunanuk, CC0Turkish TV drama is watched from Latin America to the Middle East, and much of it is shot here.62% of Istanbul’s 53 titles since 2013 are series.
Split by decade, the average goes west in the 1910s, east by the 1960s, west again in the 1990s and back east since.
Every place outside North America and Europe, all periods together.Their share of locations grew from 7% before 1920 to 16% since 2013, not enough to pull the average off the North Atlantic.
All seven averages together.
Places on the far side of the globe are hidden but count toward each average.Data from Wikidata via Movie Scene Map.Made by Georgios Karamanis with Closeread.