Unfortunately because of global terrorism, the railroads are always on alert. The first thing is make sure you are on public property, remember the railroads not only own the land the tracks are on but own the land on both sides of the ROW and that differs by location. It could be as little as 15' on either side of the ROW or up to 1,000'. Something else to do, have a copy of Trains magazine, Railfan & Railroad or other railfan type publication laying on the front seat or dash of your car and make sure it's visible through the front or side windows. If approached let the officer know you are a railfan and offer to show them the magazine. You also what to read through the Photographers rights documents:
http://www.krages.com/ThePhotographersRight.pdf Remember the Photographers Rights is a guide line and gives you some idea what the officers of the law can and cannot do. Some law differ by state, that is why I say this is a guide. Also remember what the one officer said during the stop, "I don't know you!" Remember they do not know who you are, where you are from, the one thing they do know is they don't want to have a bad day, (ie end up hurt or dead) When approached stay calm, don't yell and just talk to them, if you are defensive you look like you are hiding something.
Regards,
Rich S.