The chemistry of the composition and alterations of the solid matter of the earth or a celestial body.