Generating height map of group of objects
Set your camera above the objects looking straight down. In the Render Layers tab of the properties window make sure the Z pass is enabled.
The rest of the settings are just to speed up the rendering. I used a plain emission shader as the override material. I set the samples to 1, turned off the denoising and the "Use" options: "Use Environment," "Use AO," and "Use Hair." 



Now If you look at the rendered depth pass it will look all white. However all the data is there. (A 32bit exr would show you it in other programs.)

In the compositer drop a Normalize node between the Render Layers Depth output and a viewer node to see what is really there.



Little side note. Notice the banding on the cube in this gif. That is why you should save the depth map using a high bit depth. If you use a normal 8 bit image it will not be able to store all the information and you will end up with stepped ridges instead of a smooth gradient along the different heights.