I am looking for distance measurement in AU between planets and Earth.

E.g. For Mars, Current distance, or distance of Mars from Earth at any given datetime, along with minimum (closest approach), maximum (farthest approach) distance of Mars in its orbit with respect to Earth's motion.

How do missions like Curiosity know the minimum (closest approach), maximum (farthest approach), and current distances between two bodies in their orbits?

JPL Horizons must have it, I played around but couldn't find the values I was looking for. How do I get these values from JPL Horizons? Is there any other source I have to use for this?

  • 1
    $\begingroup$ My answer here has a live Sage / Python script that uses Horizons to graph the distance between bodies. It doesn't calculate maxima & minima, but it does calculate the mean. $\endgroup$
    – PM 2Ring
    Commented Feb 16, 2022 at 22:29
  • $\begingroup$ Interesting. Thank you! $\endgroup$
    – Majoris
    Commented Feb 17, 2022 at 6:56

2 Answers 2


You can get some of the numbers you need from JPL Horizons but you will need to have something go over the results to get the minimum and maximum values over the time span you are interested in.

If you go to to JPL Horizons it will look something like this (you may get different defaults if you've been there before): Initial JPL Horizons screen

You need to change the 'Ephemeris Type' to 'Vector Table' and then select the 'Target Body' by hitting Edit. You can then type in a target; putting in Mars will result in a list of options asking you to clarify which "Mars" you meant: Entering Mars into the JPL Horizons Target Body selection box I'm assuming you want you want Mars (the planet) itself, rather than one of the spacecraft or the barycenter (slightly displaced from Mars's center due to Phobos and Deimos) so you should select 'MB: Mars'

Next you need to select the coordinate center where you want the vectors and distances from - in your example this will be the geocenter which is code 500 in Horizons (@earth works as well but will popup a list asking whether you want the geocenter or the Earth-Moon Barycenter):

Selecting the coordinate center in JPL Horizons

You can then select the start and end times and the step size for the results that you want to cover. The default output is setup to provide a (somewhat) human readable HTML table with the full state vector ($x, y, z$ and velocities in $\dot{x}, \dot{y}, \dot{z}$), the light travel time, the range and the range rate. Since you are just interested in the range, I suggest you go into 'Table Settings' and select option 6. under output quantities to get the light time, range and range rate and set it to 'au and days'. For ease of later analysis, I would suggest you tick the CSV output as well so it looks like this:

Configuring the vector output in JPL Horizons

(you can also have output in km and seconds rather than au and days if you want). Hitting 'Generate ephemeris' will then produce the output table. There will be a header at the top with details about the target body and the settings you have chosen and the main table will start (with $$SOE) after a table header:

Vector table output for Mars from Earth from JPL Horizons

This will have the Julian and calendar datetimes in Barycentric Dynamical Time (TDB) and then the light travel time (LT; in days in this case), the range/distance (RG; in au here) between Earth and Mars (geocenter to center of Mars or whatever you actually set the target and coordinate center to) and the range rate/change in distance (RR; in au/day) - the quantities in the output are explained in more detail below the table.

As for getting the minimum and maximum separation, as far as I know there is no way to do this in Horizons directly. You would need to download the results table (in CSV format) and load it into a spreadsheet to calculate a MIN() and MAX() on the RG column or use something like Python+AstroPy to read the table in and do the min/max on it. If you do want to use Python, then you could use astroquery to query JPL Horizons directly and get an Astropy Table back which can be manipulated as you like.

  • $\begingroup$ Thank you for the answer. Is the RR radial velocity same as orbital velocity. Are these two different things? $\endgroup$
    – Majoris
    Commented Feb 22, 2022 at 14:16
  • $\begingroup$ No, it's just the change in the line of sight distance between Earth and Mars. Some of this will be due to the orbital motion of Mars but not all. $\endgroup$ Commented Feb 24, 2022 at 16:19

On this page, press Play [>] and all your questions will be answered. http://orbitsimulator.com/gravitySimulatorCloud/simulations/1645206515114_earth_mars.html It uses JPL Horizons as a starting point on 1/1/2022, and integrates into the future / past, telling you the distance & speed between Earth & Mars. For closest & furthest approach, look at Radial velocity. When it changes signs (which it does as it passes through 0 radial velocity), you are either at a max or a min. screenshot


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .