I have already talked about this in another similar thread.
It seems to me that David's sin was not taking the census per se. Exodus 30:11-15 says that whenever Israel were to be summed/numbered/counted, offerings were to be made. David didn't offer sacrifices when he took the census. This coupled with the fact that David could've taken the census just to boast about how many people he was ruler of/over. It showed pride. The other times where census were taken, they were for the purpose of the priesthood, military - they were about to go to war or wanted to know who was old enough to serve in the military - or was instructed by God. This particular census by David doesn't seem to fit any of these.
About the Gibeonites - God wasn't the one who came up with the idea of offering the "seven men" to the Gibeonites. The text says that it was the Gibeonites and they specifically ask for people of Saul's house - descendants of Saul because it was Saul who murdered lots of Gibeonites. The reason why they asked for the lives of Saul's descendants could be that since those who died couldn't procreate anymore or continue their family life, the Gibeonites wanted to do the same to Saul but the text says that David felt sorry for one of Saul's children so he didn't offer him up.
justahuman - but super nonetheless