I was about to go repelling off a suspension bridge in [place deleted]. A cop came up and told us it was illegal. We stopped setting up, and as we were about to leave, he asked all of us our names, s.s.number, address. One of us tried to refuse; the cop then threatened us with arrest (for "loitering"). We gave him the info. Then he took my friend to the back of his police car, called the FBI (my friend is a local anarchist/organizer), took his photo, and after 15 min, let him go. Is this legal?
Generally, the police can demand identification under two circumstances: if you are suspected of a traffic offense, or if you are in a state with loitering laws and you are violating them.
If you are driving and are stopped by the police for a traffic violation, they have the right to demand identification.
In those states with loitering laws, the police can demand identification of a person loitering, usually defined (at least according to Nolo.com, a legal publisher's website) as "wandering about from place to place without apparent business, such that the person poses a threat to public safety."
That's the short, layperson's answer. An analysis of this issue by someone with legal training is provided at