Mapping Google search volumes of ‘global warming’ in R

infoart.ca
2 min readFeb 11, 2024

--

Analyzing search volumes on a specific topic can provide insights into public interest and awareness about a global issue. In this blog post, we will map and compare Google search volumes of global warming using the gtrendsR package.

library(gtrendsR)
library(ggplot2)
library(maps)

Search volume of “global warming” in 2010

#extract the data
gt <- gtrends("global warming", time = "2010-01-01 2010-12-31")

#get world map data on lattitude and longtitude
world <- map_data("world")

#keep countries with at least 1 search hit
df <- gt$interest_by_country %>%
filter(location %in% world$region, hits > 0) %>%
mutate(region = location, hits = as.numeric(hits)) %>%
select(region, hits)

#make the plot

ggplot() +
geom_map(data = world,
map = world,
aes(x = long, y = lat, map_id = region),
fill="#ffffff", color="#ffffff", size=0.15) +
geom_map(data = df,
map = world,
aes(fill = hits, map_id = region),
color="#ffffff", size=0.15) +
scale_fill_continuous(low = '#F94144', high = '#43AA8B') +
theme(axis.ticks = element_blank(),
axis.text = element_blank(),
axis.title = element_blank(),
legend.title = element_blank(),
legend.position = 'bottom')

Now repeat the process for 2020

gt <- gtrends("global warming", time = "2020-01-01 2020-12-31")


world <- map_data("world")

df <- gt$interest_by_country %>%
filter(location %in% world$region, hits > 0) %>%
mutate(region = location, hits = as.numeric(hits)) %>%
select(region, hits)

ggplot() +
geom_map(data = world,
map = world,
aes(x = long, y = lat, map_id = region),
fill="#ffffff", color="#ffffff", size=0.15) +
geom_map(data = df,
map = world,
aes(fill = hits, map_id = region),
color="#ffffff", size=0.15) +
scale_fill_continuous(low = '#F94144', high = '#43AA8B') +
theme(axis.ticks = element_blank(),
axis.text = element_blank(),
axis.title = element_blank(),
legend.title = element_blank(),
legend.position = 'bottom')

Here are the two maps together…

Far more countries are now searching for the term ‘global warming’ than in 2010.

--

--

infoart.ca
infoart.ca

Written by infoart.ca

Center for Social Capital & Environmental Research | Posts by Bishwajit Ghose, BI consultant and lecturer at the University of Ottawa

No responses yet