As pointed out one is trespassing when on railroad property. The main concern of common carriers is safety and more importantly, vandalism, especially in post 9/11 America. And the dangers are many including being struck by a train just as there are differing reasons for one to be on the tracks. The dangers are enumerated below so if one is going to trespass protect against these. Some are rules employees must follow as well.
1. Uneven footing abounds. Wear proper foot-ware. Boots with high ankle support will guard against a sprained ankle.
2. Never step on top of the rail. There is plenty of slippery stuff along the right of way, such as curve grease, oil or crater (a heavy lubricant used on locomotive traction motor gear boxes). Step on the rail and you can go down. Bash your head and wind up unconscious the next train along is going to run over you.
3. If walking along with another person or a group, walk in single file.
4. ‘Flash.’ On the inside of the ball (top) of worn rail there are very thin strips of steel resulting from wear. It is as sharp as a surgeon’s scalpel and will lay your ankle open to the bone. Another reason for wearing proper foot-ware.
5. There is danger to be found with passing trains. Shifted loads can have lading protruding out the side where open loads are concerned, such as lumber on a flatcar. In addition these loads have many steel bands in place securing the load. They can break and when they do they get very sharp very quickly while dragging along the ballast (gravel) that the ties (sleepers) and rails the trains run on. It will cut you in two if it hits you. In addition a train can derail at any place, any time and at any speed for varying reasons.
6. Most tracks are found in rural areas. Many people use them as a short cut because the going is easier. So do some animals which consider you as a meal. Where I live there are bears and mountain lions (cougars) and others that may attack, such as coyotes and bob cats. As darkness falls rattlesnakes love to lay along the rail soaking up the heat that was made during the day. Even stag deer will attack during rutting season.
7. Locomotives don’t just pull cars around. They push them too. If the engine is a mile away you will not hear it and the equipment being pushed can sneak up on you in near silence.
8. Whenever possible, if absolutely needing to do so, go around standing equipment do so no closer than 50’ away and expect the movement of that equipment or nearby equipment at any time in either direction on any track. NEVER cross a train on the car's end platforms, couplers or crawling underneath.
A train doesn't need to be speeding along to kill you. Its punch is do to the mass. Freight trains typically tip the scale between 8,000 to 13,000 tons. Put another way, if I throw a bullet at you it would not do much harm but you still wouldn't want to take one in the eye, do to its low mass. But if I fire it at you, it wills pass through your body. It gets its punch through low mass at high speed. A train is a reverse bullet, if you will. Massive weight moving at slower speed. Statistically most fatalities and injuries occur when the train is moving at or less than 30mph.
The best idea is to stay off the right of way but if you are going to go there do so practicing these suggestions. It may save your life and limbs.