|This article is about the current version of DF.|
There are four types of stone layers in Dwarf Fortress, very much based on real life geology (see below). Stone layers are roughly homogeneous layers of rock that are composed of the same kind of stone, and usually contain different ores. Each stone layer has its distinct markers and qualities; sometimes a clear dividing line can be drawn between two biomes from the stone layers underneath, sometimes not. Digging deeper or digging into another local biome will reveal differences between contents and a progression from sedimentary down to igneous.
These changes are usually quite sharp; fifteen layers may be mostly quartzite, but the next thirty layers may be dominated by gabbro. Three dimensional variance is planned for the future, but for now, changes between stone layers also mark changes in ore and gem content.
Most maps have one or a few layers of soil at the very top, although this layer may be completely non-existent or ten or more layers deep as well. Note that on mountainous terrain, soil tends to accumulate near edges; thus you can have partial soil "layers" down the side of the mountain for quite a few z-levels.
Soil is important for three reasons: it is easily farmed (not requiring irrigation like stone does), it is easily mined (taking less time than stone), and it does not leave any loose stone behind when mined. Soil layers can contain clay and sand, if your biome has any, as well as a high chance of being an aquifer, if your biome has one. Soil layers do not contain ores or gems. At least one layer of soil is necessary to easily establish farming. It is not recommended you establish your main fortress in soil, as it cannot be smoothed or engraved to make it visually appealing/more valuable.
The sedimentary layer has an 80% chance of being the first stone layer that appears after any soil. It will include any lignite or bituminous coal, if you are lucky enough to have some. Iron ore and all but one of the fluxes is common here as well, making the sedimentary layer make-or-break for steel production. Note that this layer and the igneous extrusive are mutually exclusive, and will never be found in one place. Sedimentary layers are generally where the bulwark of the fortress will find itself, will contain most of the ores marked on the embark screen as "shallow metals", and is a good choice for exploratory mining. Note, however, that it is poor in gem content - those found in sedimentary layers are generally less valuable than those further down. Some types of sedimentary rock may contain an aquifer.
 Igneous extrusive
In certain regions igneous extrusive layers replace sedimentary layers as the top-most layer of stone. Besides being made of different rocks, they are generally very similar to sedimentary layers, with the exception being that they often indicate the presence of magma above the magma sea itself. This is always the top-most layer near volcanoes; the biggest stumbling block is that its presence means that the biome very rarely contains any flux.
Contains a small variety of vein ores, as well as marble, the one non-sedimentary flux. Metamorphic layers generally contain moderately valuable gems, and if the sedimentary layer (or and especially igneous extrusive layer) above contains no flux stone, it is a useful early target for exploration in the hopes of finding flux. It does lack weapon-quality ores (containing only copper and silver).
 Igneous intrusive
This is the deepest and often widest level, and leads directly into the magma sea. Gems here are generally the most valuable, on average. The most valuable of them all, colored diamonds, are found within faint yellow diamonds within kimberlite within gabbro layers.
 In real life
Being modeled on basic geology, much of the way stone layers work in Dwarf Fortress also applies to our planet. At the surface of the world there's a thin covering of soil, a soft mixture of minerals (the building blocks of stones), small rocks (sand, silt, clay etc.), liquids, living things and so on. Below that there's a sedimentary layer of stones; these are made of particles of minerals, organic detritus and other stuff, which, after tumbling around, end up settling down below ("sedimenting"). Those grains and particles are then glued together into new rocks ("cemented") by various process; for example, by mineral growth of substances carried by water (similar to how stalactites grow).
Below the sedimentary layer the rocks are subjected to heat from below, and pressure, stretching etc. from the movement of continental plates. Those forces transform them into different kinds of rocks, called metamorphic.
Further down, as things get hotter still, rocks melt into magma. If magma escapes the heat, it may cool and harden while still underground, forming the igneous intrusive ("fiery inside") rocks. In DF these form a layer below the metamorphic stones, but in real life they may form anywhere there are cracks for the magma to fill in. If the magma rises all the way up to the surface and is expelled by a volcano, we call it lava. The lava cools down into igneous extrusive ("fiery outside") layers, which in DF replace the sedimentary layers in some biomes near volcanoes.