2 Samuel 24:17-19

24:17 When he saw the angel who was destroying the people, David said to the Lord, “Look, it is I who have sinned and done this evil thing! As for these sheep – what have they done? Attack me and my family.”

David Acquires a Threshing Floor and Constructs an Altar There

24:18 So Gad went to David that day and told him, “Go up and build an altar for the Lord on the threshing floor of Araunah the Jebusite.” 24:19 So David went up as Gad instructed him to do, according to the Lord’s instructions.