Limestone forms the massive overhang above and the ledge below, while softer layers of silty limestone between them retreated through erosion to create natural alcoves like this one, where all of the more than 300 cliff dwelling rooms in Walnut Canyon were built. These rocks are the same sequence seen in Grand Canyon: the Kaibab Formation as the rim rock, with the Toroweap Formation and Coconino Sandstone below. Diagonal cross-bedding in the sandstone across the canyon preserves sand layers that record changing wind direction. The Kaibab Formation was formed by deposits of calcium carbonate in a shallow sea near an ancient shoreline about 250 million years ago, and the lower formations were formed in a near-shore environment of stream-deposited sediments and windblown sand dunes about 265 million years ago. During the Permian age, roughly 286 to 248 million years ago, northern Arizona lay along a shoreline.