RALEIGH, N.C. -- Transportation officials and railroad companies are sounding a warning: Active railroad tracks are a bad backdrop for prom pictures or selfies.

With the season for graduations and prom portraits underway, North Carolina's transportation and public school agencies this month are urging high school yearbook staff advisers to reject student photos taken on or near railroad tracks. They're emphasizing that railroad selfies can be as dangerous as stopping for a snap in the middle of an interstate or airport runway.

"You put your life at risk by trespassing on railroad tracks," said Paul Worley, the rail division director at North Carolina's Transportation Department. "We need photographers, school administrators and parents to educate students about the potential danger of taking photos on railroad tracks."

North Carolina officials say 21 people were killed while trespassing on railroad tracks last year, but none of the deaths was due to risky photography, said Margaret Cannell, head of the North Carolina division of the railroad-backed safety group Operation Lifesaver. Railroad tracks are private property and walking on or hanging around them can be dangerous, Cannell said.

"People expect a train to be really loud, but they're quieter than ever before," The News & Observer of Raleigh quoted Cannell as saying. "So you won't always hear a train approaching."

Nationwide, 511 people died last year while trespassing on railroad tracks, a 13 per cent increase over 2015, Operation Lifesaver said.

A 19-year-old Texas woman was killed by a train last month while having photos taken of her on the tracks in a bid to launch a modeling career. Fredzania Thompson stepped out of the way of an approaching train about 100 kilometres northwest of Houston, but she was struck when she stepped into the path of a second train coming in the opposite direction, authorities said.

Trying to drive home the message, Omaha, Nebraska-based railroad Union Pacific this spring extended its campaign to steer people away from railroad tracks with a series of animated videos about the potential dangers. The short videos highlight the risks of taking a selfie on railroad tracks or posing for high school senior pictures on or near train tracks. The videos are designed to be easily shared on Twitter, Facebook, YouTube and other social media sites.