A woman who allegedly hitched a ride on the top of a freight train as it travelled at speeds of up to 115km/h in western NSW has been charged by police.

After clinging to the top of the train for the four-hour journey from Broken Hill to Ivanhoe, the 27-year-old woman jumped from the roof of the train as it stopped at a railway station and walked away uninjured, police allege.

Police said the train driver saw the woman climb on to the roof of the freight train as it stopped at Broken Hill about 3am on Tuesday.

The train continued on its 320km journey and reached speeds of 115km/h before stopping at Ivanhoe Railway Station.

The train driver contacted police and gave them a description of the woman.