The standard for stopping someone and requesting their ID under the limitations in the U.S. Constitution is "reasonable suspicion."
For example, if the officer has a reasonable suspicion that you are taking pictures for the purpose of a secure location for purposes of espionage, or to case the location for a future crime, reasonable suspicion is probably present and you can probably legitimately be asked for you ID.
A creative and intelligent officer can almost always conjure up some reasonable suspicion in the situation that you identify to question you and demand ID. For example, she could state that no one else has taken a picture of that location in weeks and that is is very unusual behavior, that your demeanor or the time of day you were present doesn't seem to be that of someone taking a picture for artistic or journalistic purposes, that you seemed nervous, that a previous criminal engaged in similar behavior before committing a crime fourteen years ago, that a confidential informant (e.g. a nosy neighbor) advised him that there was someone engaged in suspicious behavior at that location, that she read in a police anti-terrorism bulletin that terrorist favor that model of camera, etc.
The nature of the suspicion doesn't have to be shared with you until you challenge it in court.
A dumb cop won't come up with any colorable reason, demands ID for a stated reason ("before you have to do whatever I say") that is inaccurate, admits he has no reason to stop you in a conversation captured by a body camera, and doesn't come up with pretext after the fact before going to the court. In that case, the stop is a de minimis violation of your civil rights justifying a nominal damages award of $1 to you and your attorneys' fees and costs and maybe a consent decree ordering the agency not to do that in the future.