A heightmap or heightfield is a a 2D array of height values in a regular grid. For each location (x,y) in the grid a value is stored and that value is the height of the terrain at that (x,y) location. This can all turn into huge set of data for a big terrain so instead of a float the height can be stored as a byte or word and scaled to the correct height when it is used.
It is common to display and edit heightmaps in the form of a grayscale image. Both of them are 2D and contain a single value so all that is needed is to map the value in the heightmap to a grayscale color. Low areas of the terrain is black and the higher up it is the brighter it gets.
Terrain and heigtmaps can be created with procedural generation.
Real world areas
Some areas of the world (and mars) have elevation files that describe the terrain. One of the common formats is the USGS DEM format. Something for flight simulators that wish to have a real area to fly over.