The mental processes involved in gaining and using knowledge and beliefs about spatial environments. Spatial cognition includes issues of perception, memory, language, learning, and problem solving, and is an object of study in humans, nonhuman animals, and machines.