Petrology is the branch of geology that studies rocks. It includes the origin and formation of rocks (petrogenesis) and their classification and description (petrography). There are three main types of rocks: igneous, sedimentary, and metamorphic. Igneous rocks form from cooling magma or lava. Sedimentary rocks form from the compaction and cementation of sediments. Metamorphic rocks form from changes to existing igneous and sedimentary rocks via heat, pressure, and chemical reactions.