Boredom, neglect, territorial, alarm, startled. These are all reasons for dogs to bark. Some breeds are barkers, though, and their owners should know this and not bring them camping if they can't control them.
Also, some specific dogs are bad-mannered because of their lack of training with their owners. Definitely the owner's fault.
I just had a similar run-in close to what Dan described. I was running Sunday morning on a country road in farm land and a big-azz black lab booking across a field straight for me. It caught up to me and crossed the road coming at me at full speed and I had to stop running as I was afraid the thing was going to hamstring me.
A lot of yelling while waving a big branch like a baseball bat actually startled it and it ran away. I'm surprised it left me alone as it was pretty aggressive. After it left, I yelled across the field for the owner to get control of their pest (I mean pet).
I really, really wish I had some of that pepper spray. I would have had no problems spraying it.
DW, 3 Kids and our Goldens
2012 Shamrock 233S
2008 Toyota Sequoia 5.7L 4WD