CALGARY -- Former United States president Barack Obama called on global leaders to pay attention to the ways the world is rapidly transforming, urging action on climate change and wealth inequality in speeches in Western Canada on Tuesday.

Obama spoke first to a near-full arena in Calgary, home to several oil and gas company headquarters that are replete with empty office space due to a years-long industry downturn.

"All of us are going to have to recognize that there are trade-offs involved with how we live, how our economy is structured and the world that we're going to be passing on to our kids and grandkids," Obama said. "Nobody is exempt from that conversation."

He said fossil fuels have provided a cheap and plentiful source of energy since the Industrial Revolution. The remark drew a loud whistle and applause from the audience.

The crowd also clapped when Obama said there is indisputable science that the planet is getting warmer.

"At the current pace that we are on, the scale of tragedy that will consume humanity is something we have not seen in perhaps recorded history if we don't do something about it."

Rising oceans will displace populations from coastal areas and climate change is also having an effect on the prevalence of insect-borne diseases, he said.

"Moose right now (have) to deal with tick-borne diseases that they didn't have to do 10, 15 years ago," Obama said. "I really like moose. I assume Canadians, you, do too."

He said the question becomes how to build recognition, not just generally, but in places such as Alberta, that newer energy sources need to be developed and older ones have to be cleaned up.

Obama said the chaos wrought by global climate change will make politics more toxic.

"Imagine when you have not a few hundred thousand migrants who are escaping poverty or violence or disease, but you now have millions," he said. "Imagine if you start seeing monsoon patterns in the Indian subcontinent changing so that half a billion people can't grow food and are displaced."

The same engineering prowess that's been used to tap tough-to-access oil can be directed toward finding cleaner sources, Obama suggested.

"You guys can figure it out, but you've got to be open to it."

Obama rejected the Keystone XL pipeline in 2015 after years in regulatory limbo. The proposed project, which would allow more oilsands crude to flow to refineries on the U.S. Gulf Coast, has the support of his successor, President Donald Trump, but the pipeline remains mired in state-level legal wrangling.

Obama recalled with a mixture of amusement and frustration how in 2015 Republican Oklahoma Sen. James Inhofe, then chairman of the environment committee, brandished a snowball on the senate floor to dispute climate science.

"You laugh. This happened," he said. "That's not a good way of approaching problems."

Obama later spoke to a sold-out crowd of thousands at a Greater Vancouver Board of Trade event, where he said being president gave him insight into how quickly the world is changing.

Globalization, automation, the internet and social media have accelerated the ability of some businesses, such as those in Silicon Valley, to rapidly expand, he said. But at the same time, these innovations have displaced some workers who used to lead secure middle-class lives and led to culture clashes, he said.

Current U.S. politics, Brexit and the rise of far-right nationalism in Europe can all be seen as responses to these forces, he said.

He said he worries about the sustainability of an economic order with such a vast wealth gap.

"You start getting extreme political movements in reaction," he said, adding: "These changes are just beginning."

Obama said he expects artificial intelligence to revolutionize the job market over the next 25 to 50 years, pushing out many high-skilled workers. He expressed concern that countries are not well-prepared for the shift, although he said Canada is likely better positioned than the United States because it has a more robust social welfare system.

He also criticized the Republican party for embracing right-wing populism, and he traced it back to the late senator John McCain's decision to select then-Alaska governor Sarah Palin as his running mate in the 2008 presidential race.

"That was the moment when the Republican party changed," he said.

There has always been a strain of nativism and suspicion of elites in the party, he said, but Palin brought those attitudes to the fore and laid the groundwork for Trump's presidency.

Obama's talk in Vancouver had its lighter moments, too. Asked about the American-Canadian relationship, he said the two countries will always be friends and the tensions between them can often feel "incidental" on the scale of global politics.

He recalled his final meeting with Justin Trudeau, when the prime minister only wanted to talk about timber agreements. Obama stressed that he understood forestry was important to Canada, but he joked that it was of slightly less consequence than other issues he was grappling with.

"I'm like, 'Dude, I got Syria,"' Obama recalled, to laughs from the crowd. "The Paris Accord. The Iran nuclear deal. And this is how you want to spend our time? Timber?"

"Again, I understand (timber agreements) are important here, but it's not India and Pakistan."

With files from Laura Kane in Vancouver