For wide landscape and Milky Way photography, the trick is getting both a near foreground and the stars at infinity acceptably sharp in one frame. The hyperfocal distance is the focus point that does exactly that. This calculator finds it for your lens and sensor, and shows the near and far limits at any focus distance.
How it works
The hyperfocal distance depends on focal length, aperture and how forgiving your sensor is about blur (the circle of confusion):
H = f² ÷ (N × c) + f
where f is focal length in mm, N is the f-number, and c is the circle of confusion for your format. Focus at H and everything from H/2 to infinity is acceptably sharp.
For a subject focused at distance s, the sharp zone runs between:
near = s(H − f) ÷ (H + s − 2f) far = s(H − f) ÷ (H − s)
When s reaches H, the far limit goes to infinity — that is the hyperfocal condition.
Example
A 24 mm lens at f/8 on full frame (c = 0.029 mm) gives a hyperfocal distance of about 24² / (8 × 0.029) + 24 ≈ 2.5 m. Focus there and everything from roughly 1.25 m to infinity — foreground rocks and the Milky Way — falls inside the sharp zone.
Notes
“Acceptably sharp” is judged at normal print-viewing size, so for big enlargements or critical pixel-level sharpness, focus a little past the hyperfocal distance or stop down one more stop. Smaller sensors have a smaller circle of confusion, which pushes the hyperfocal distance further away. All calculations run locally in your browser.