A lot of the time, police have said “you can't photograph..." and not "it
is illegal to photograph...”. I wonder if that means anything.
If it's not illegal, you can ... Obviously, you need to exercise some
judgment with a cop (or even a psycho security guard). Even if you're
right and he's wrong, he's likely to win a street confrontation.

They were extremely serious when it came to the “transportation
system”, though.
Ask them to cite a law. Nicely, of course. A fair number of
similar incidents have been reported, and with the exception of proposed
laws in New Jersey, I've not seen anyone cite an actual law that forbids
photography of transit systems. Again, it's hardly as if I've researched
every law in every city and every state.