If I'm taking pictures near tracks my rule of thumb is be as close to a crossing gate as possible. By me, they blow their horns even if the gates go down. That way you know they're coming. But rarely do I take photos on tracks away from the gates. IMAGE LINK: https://flic.kr/p/bjwA7C IMG_7805_6_7.jpg
by Alan Mars
, on Flickr
That's one of my favorite shots. When I took this I kept looking behind me to see if there was anything coming. Also, there's a road that crosses these tracks maybe 1,500 feet away which was behind me when I took this and the tracks ahead of me turned 90 degrees so if a train were coming I would have heard it and I don't think they travel very fast through there anyway being that it's a residential neighborhood with a 90 degree turn on it.
You just have to be very careful and aware of your surroundings. Maybe if there is a model involved you lose concentration of what's going on around you. That's something I've never tried before and probably something I won't try ever.