A canal lock connects two bodies of water at different elevations by creating a water elevator of sorts. The water inside the lock can be raised and lowered independently, allowing ships to make the transition between elevations without the danger of traveling down rapids or the difficulty of steaming uphill.
To raise a ship, the water in the lock is lowered to match the water in the lower canal. The ship moves from the canal into the lock, where a set of doors seals it off from the lower canal. Sluice gates in the other end of the lock are opened, allowing water to flow down from above and raising the water level. When the water levels are equalized, the doors in the far end open, allowing the ship to move out into the upper canal. The process is simply reversed for ships traveling into a lower canal.
Canals are vital for allowing waterways to follow the terrain rather than having to cut through it. The Panama Canal has three sets of locks, requiring a ship to be raised three times and lowered three times to make the journey from one ocean to the other. The Erie canal, on the other hand, has 57 locks that raise ships a total of 566 feet from one end of the canal to the other.