Sometimes I keep the setting, such as Naples, Florida in A TRICK OF THE LIGHT. Most of the time I change the name so I can take some literary license as far as landmarks and geographical aspects go. That means I can run a river right through the center of town if I want or change the way the town lays out.
I also do it to protect the law. Specifically, my books often involve situations where the heroine gets no help from the law. I don’t want her to get help; that’s the point. I want her on her own, fighting for justice and her life. I try not to make the police or sheriff numbskulls, but they usually have reasons for not wanting to help or not believing the heroine. Sometimes they’re downright corrupt. Particularly when I’m dealing with a smaller town or city, I don’t want to offend the real life law enforcement officials.