Just as the doppler shift of an incoming train whistle makes the pitch sound higher, and when the train is moving away from you the pitch sounds deeper, the velocity of a galaxy moving towards us or away from us will shift the frequency and wavelength of the features in its galaxy spectrum.
The relationship between the shift in wavelength of a given feature and the velocity of the galaxy which emits the light is well understood for nearby galaxies. The velocity v in terms of c, the speed of light, is equal to the difference between the observed wavelength of the light and its restframe wavelength, in terms of the restframe wavelength. We write these words as an equation like this:
To calculate the velocity, we select a feature that is present in both the restframe spectrum and the spectrum of the moving galaxy. We measure the wavelength of the feature in both spectra, and use these values for the restframe and observed wavelengths.
We can also calculate the distance between the Milky Way and this galaxy. We know that the expansion rate of the Universe is 72 kilometers per second per megaparsec.
To beocme comfortable using this expansion rate, we can make an analogy between the movements of a galaxy and those of a vehicle. Imagine that a friend leaves town and drives away at a steady, constant speed. How far away will she be after one hour has passed? A driver moving at a speed of 30 miles per hour will be 30 miles away, a driver with a speed of 60 miles per hour will be 60 miles away, and a driver with a speed of (gulp) 120 miles per hour would be 120 miles away.
We measure the relative velocities of cars in units of miles per hour, and those of galaxies in units of kilometers per second. We measure the distances between cars in miles, and those between galaxies in in units of megaparsecs. We can use the expansion rate to convert from galaxy velocity to galaxy distance, as follows. For every 72 kilometers per second in velocity that a galaxy is moving away from us, it lies a megaparsec futher away. A galaxy with a velocity of 72 kilometers per second is one megaparsec away, a galaxy with a velocity of 144 kilometers per second is two megaparsecs away, and a galaxy with a velocity of 720 kilometers per second is ten megaparsecs away.