Less than 24 hours after he addressed the deadly police shootings of two black men in Minnesota and Louisiana, U.S. President Barack Obama said America should be "horrified" by the subsequent sniper attack on officers in Dallas.

Speaking this morning from Warsaw, where he's meeting with leaders of the European Union and attending a NATO summit, Obama asked all Americans to pray for the police and transit officers — killed and wounded when a sniper opened fire late Thursday during a protest against police brutality in the Texas city — and their families.

"We still don't know all of the facts. What we do know is that there has been a vicious, calculated and despicable attack on law enforcement," he said.

He also said the nation should express its gratitude to those serving in law enforcement.

"Let's be clear, there is no possible justification for these kinds of attacks," he said.

Earlier Friday from Warsaw, Obama also called on American law enforcement to root out bias in its ranks and said all Americans should be "troubled" by frequent police shootings of blacks and Hispanics, insisting that the fatal incidents in Minnesota and Louisiana are not isolated.

Adding his voice to a growing public outcry, Obama said the shootings were symptoms of a "broader set of racial disparities" in the justice system that aren't being fixed quickly enough.

U.S. president delivers a statement about this week's deadly police shootings in Louisiana and Minnesota 16:37

He ticked through a list of statistics he said showed concerns about bias are real: African-Americans being shot by police or arrested at more than twice the rate of white Americans.

"When incidents like this occur, there's a big chunk of our fellow citizenry that feels as if it's because of the colour of their skin, they are not being treated the same," Obama said. "And that hurts. And that should trouble all of us."

Obama's diagnosis of the problem reflected a growing sense of frustration and willingness to speak out publicly about police killings despite the risk of making law enforcement officers feel under attack.

He largely echoed comments he made earlier in the day in a Facebook post as the two deaths were increasingly capturing the country's attention.

In Louisiana, 37-year-old Alton Sterling was fatally shot Tuesday as he tussled with two white officers outside a convenience store in a predominantly black neighbourhood. The shooting was caught on tape and went viral online.

The next day in Minnesota, 32-year-old Philando Castile was shot to death during a traffic stop. His girlfriend posted video of the aftermath live on Facebook, saying he had been shot "for no apparent reason" while reaching for his wallet, as an officer had asked.

Though the White House has sought to avoid commenting on specific cases before all facts are known, in this case Obama weighed in while both shootings are still being investigated, including a civil rights probe by the U.S. Justice Department into the Louisiana incident.

On Friday evening the White House announced Obama will shorten his European trip by one day, returning on Sunday night, and he will travel to Dallas early next week.

Protesters gather outside Minnesota Gov. Mark Dayton's home on Thursday, a day after 32-year-old Philando Castile was fatally shot during a police traffic stop. Dayton has called on the U.S. Department of Justice to begin an investigation. (Corinne Seminoff/CBC)

Similar statements about other shootings have stoked tensions with law enforcement, including with FBI Director James Comey, who has suggested the intense public focus on police officers' conduct, fuelled by caught-on-camera moments, may be inhibiting officers as they try to protect their communities.

Aiming to pre-empt that concern, Obama said that speaking out about the issue is not an attack on police. He emphasized that he and other Americans appreciate the risks police officers take and mourn officers who die in the line of duty.

"When people say 'black lives matter,' that doesn't mean blue lives don't matter," Obama said, referring to uniformed officers. "That just means all lives matter."

Alton Sterling, left, and Philando Castile were both shot and killed by police this week. Each incident in the U.S. was recorded on cellphone cameras and posted online. (Alton Sterling/Philando Castile/Facebook)

Yet despite Obama's efforts to bridge misunderstandings between African-Americans and the police, the problem clearly persists. In 2014, Obama created a task force to develop modern policing guidelines, and he urged local communities and policing agencies to implement those recommendations drafted by the Justice Department.

Obama said if anything good could come from recent deadly incidents, it would be that more parts of the country would adopt those recommendations.

"Change has been too slow," Obama said. "We have to have a greater sense of urgency about this."

Obama has wrestled for much of his presidency with the policing issue, the "Black Lives Matter" movement and his role as the first black president in responding to them. After the issue burst into the spotlight in 2012 with the shooting of 17-year-old Trayvon Martin in Florida, Obama insisted the U.S. take the issue seriously and added, "If I had a son, he'd look like Trayvon."