Optimal Aperture For Foreground Sharpness With Infinity Focus (meters)
What this graph shows
To get greater depth of field you need to use smaller apertures. But lenses also become less sharp at small apertures due to diffraction. There is therefore an optimal aperture to use to get the foreground as sharp as possible, which is what this graph shows.
It is usually best to focus on the object that you want to be the main subject of your shot. When that's a mountain, hill etc it is often a long way off. An approximation to this is "infinity", marked on most lenses with the infinity symbol which looks like a sideways 8. If you have an autofocus lens it is probably best to focus directly on the far point than to set it manually, but in low light autofocus becomes unreliable so it is probably better to use infinity focus.
Choosing an aperture
When the whole of the scene is a long way off choosing an aperture is easy. Most lenses are sharpest at about f/8, so that's the aperture to use. When you want something closer to be sharp too it gets more tricky.
How to read the graph
Suppose you are using a 22mm lens focused at infinity. Something in the foreground is 4m away. The point at which 4m and 22mm intersect is closest to the f/13 line, so f/13 is the aperture to use.
Suppose you are using a 50mm lens focused at infinity. Something in the foreground is 2m away. No line on the graph is close to this. At this point you need to re-think your shot and move further from the foreground, otherwise it will be intolerably soft. 8m to the foreground will allow you to use an aperture of f/22.
Suppose you are using a 10mm lens focused at infinity. Something in the foreground is 3m away. You're above the f/8 line so f/8 will work just fine.
The lines are drawn though points where the Circle of Confusion is the same size as the Airy Disc. The relationship holds whatever sensor size your camera has - no conversion factor is necessary (you should use actual focal lengths to read this graph, not 35mm equivalents).
The longer the focal length you use the smaller the aperture you will need to use to get the foreground sharp, or the further you need to move back. If you want to get really close to the foreground, and get sharp shots, a wide angle lens is a must.