I am glad that you decided to show the police your ID. You may not have been required to, and you may have been in your rights not to (depends on the jurisdiciton), but strategically, I feel it was the right decision you made.
But
What do you think would have happened, if you had just shown your ID to the police officer when first asked? The whole thing could have quickly become a non-issue.
Yes, you were not trespassing
Yes, you were not breaking any laws
Were you doing something that might be considered suspicious? Yes
The police have a responsibility to investigate that which appears to be suspicious and part of that investigation would include getting the name of the person.
Refusing to show ID... do you think that will make you appear more or less suspicious? What did you think the police officer's reaction would be?
What do you think this police officer's opinion of photographers is after this incident?
BTW, telling a police officer that you are losing patience with them is probably not a good idea if you want to avoid escalation. That statement may be construed as aggressive as it is implying (threatening?) a potential future action.
"Starting now, I think I will inform law enforcement as to my whereabouts when I go out photographing, especially during nighttime. I've been stopped several times now. "
That might be a good idea. Especially if you are in an area where there is a smaller police department. Please keep in mind that you had far more information than the police did concerning this incident.... you knew that you were just a photo nut and not a terrorist nut. But the police officer did not know this. I don't know where you were, but there are areas in the US where the police have a consequentialist attitude when it comes to "public service".
It sounded like you handled this pretty well and remained calm. I am glad it did not escalate.
Next time, you might not be lucky enough to have a police office as patient as this one was.