I'm trying to take photos of the moon with other objects in the foreground but I can't seem to get both in focus. How far do I have to be from the tree to have pan focus (foreground and background in focus)? I'm using a Sony 55-210mm lens, and I already tried stopping it down to f36, which didn't work.

  • \$\begingroup\$ autofocus or manual focus? \$\endgroup\$ Commented Mar 12, 2017 at 0:20
  • \$\begingroup\$ How far away is the tree? \$\endgroup\$ Commented Mar 12, 2017 at 0:20
  • 2
    \$\begingroup\$ Possible duplicate of How can I get everything in focus? \$\endgroup\$
    – mattdm
    Commented Mar 12, 2017 at 4:44
  • \$\begingroup\$ @HarryHarrison I'll move my camera to wherever it needs to be. I use a combination of manual and autofocus. \$\endgroup\$
    – Max
    Commented Mar 13, 2017 at 1:51
  • \$\begingroup\$ @Max Manual what? Do you mean focus? \$\endgroup\$
    – Janardan S
    Commented Mar 15, 2017 at 9:10

3 Answers 3


You'll probably never get both acceptably sharp in the same exposure.

What we call Depth of Field (DoF) is just an illusion, although it is usually a very convincing one. But it breaks down with certain subjects. Astrophotography is one subject where we can tell the background is not as sharp as we expect when using DoF formulas and calculating the hyperfocal distance.

There's only one distance from the camera that is in sharpest focus. Everything in front of and behind that field of focus is blurred to one degree or another. DoF is what we call the range in front of and behind the field of focus that appears sharp enough to fool our eyes and brains into seeing things as sharp.

You're fighting several technical limitations with the image you are tyring to take that are very difficult to overcome.

  • One is that the moon is 250,000 miles away, give or take a few thousand. Your tree is much closer. While in theory it might be possible to place both within the near and far limits of the DoF, neither will be as sharp as you probably want them to be.
  • To get a very near hyperfocal distance you must use a very narrow aperture. This leads to diffraction, which causes everything, even the point of sharpest focus, to degrade due to the higher percentage of light rays reaching the sensor that are being scattered by the edges of the aperture diaphragm. For most FF cameras, anything narrower than about f/10 or f/11 starts to show the effects of diffraction. The smaller the sensor and the pixels on it, the lower the aperture at which diffractions begins to affect the image. This is called the diffraction limited aperture (DLA).
  • The other disadvantage of using a very narrow aperture is the resulting increase in exposure time needed. Even if your camera is solidly mounted on a tripod or other stable platform and not moving at all, the moon is moving across the sky at a rate of its own diameter every two minutes. The tree is probably not totally stationary either. Any wind will cause motion in the leaves and branches.
  • The moon is lit by direct sunlight. It is very bright. Unless it is very low on the horizon the illuminated parts of the moon are properly exposed at about EV 12 (e.g ISO 200, f/8 , 1/125) or even a bit higher. Your tree is probably nowhere near as bright if it is nighttime. Unless you only want a silhouette of the tree you're probably going to need an exposure values about 15 stops slower at EV -3 (e.g. ISO 200, f/8, 256 seconds) OR put some light on the tree from an artificial light source. Even if you could get both the moon and the tree in proper focus the moon would be totally blown out if the tree were exposed to reveal any degree of detail.

There are a couple of strategies you can use to overcome these obstacles:

  • Shoot at a time when the moon is in the sky during early morning or late afternoon. By exposing for the moon the sky and landscape will appear darker than they actually appear to your eyes.
  • Composite separate images of the moon and the tree. You'll need to take the exposure of the tree when the moon is not in the field of view.

You can consult tables and charts and / or on-line computers and get the answer you want. It is called the Hyperfocal Distance – let’s call it H. H has this property – if a lens is focused on H then all points will be in acceptable focus from infinity (as far as the eye can see), down to half of H.

You can find H using simple math (with a calculator it’s easy).

The value of H intertwines the focal length (zoom setting) and the taking aperture (f-number).

The value of H In inches (sorry I was schooled in America). H = (39.37 X focal length) ÷ f-number

An example: Lens is zoomed to 100mm and the aperture setting is f/8 The math: (39.37 X 100) ÷ 8 3937 ÷ 8 = 492 That’s 492 inches We convert to feet: 492 ÷ 12 = 40 feet. (OK to round distance values).

If you set the camera’s focus distance to 40 feet and set the aperture to f/8, the moon will be in focus.

What about the foreground? We divide H by 2 to find the range of acceptable focus. Thus with the camera set to 40 feet, the aperture set to f/8, the range of acceptable focus is 20 feet to infinity (as far as the eye can see symbol,

Behind the calculation for hyperfocal distance:

What is deemed acceptable as to focus in an image is based on the permissible size of the circle of confusion. Most tables and charts use 1/1000 of focal length for the allowable diameter. Thus if the zoom lens is set to 100mm, the allowable size of the circle of confusion is 100 ÷ 1000 = 0.1mm.

Using these criteria, the hyper focal distance can be calculated by multiplying the actual diameter of the iris X 1000.

We calculate the actual iris diameter by focal length ÷ f-number. Thus a 100mm lens set to f/8 has a working diameter of 100 ÷ 8 = 12.5mm.

We now know all the fact. To find H we multiply 12.5 X 1000 = 12,500mm To convert millimeters to feet we multiply by 0.0033. H in feet = 12.500 X 0.0033 = 41 feet.


Another approach that you can take is to use a technque called 'focus stacking'.

In this process, you would shoot the same picture multiple times, but intentionally focusing on different areas that you want to have be 'in focus'.

  • Moon in focus, but foreground a bit blurry
  • Foreground in focus, but moon a bit blurry
  • Continue for as many items as you want to have in focus (or different parts of one item, if needed.

Combine the items in post, and let Photoshop do the heavy lifting of determining which items are in focus. Photoshop will then select the 'in focus' parts of each photo, which would be loaded as a 'stack' hence the name focus stacking.

This technique is frequently used for Macro photography, but it could be used for this just as well.

See https://digital-photography-school.com/how-to-focus-stack-macro-images-using-photoshop/ for more info.

  • 1
    \$\begingroup\$ The problem re:focus stacking with the moon in the frame is movement. Even if it only takes 15 seconds from start to finish the moon will have moved 1/8 its diameter during that time interval. \$\endgroup\$
    – Michael C
    Commented Mar 13, 2017 at 23:38
  • 1
    \$\begingroup\$ @MichaelClark You can deal with that using masking techniques. You just take the foreground without the sky from the tree picture. \$\endgroup\$ Commented Mar 14, 2017 at 22:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.