The Legend of Lord Ganesha and Sage Agastya is related with the flowing of the Kaveri river in South India. During the marriage of Lord Shiva and Goddess Parvati, the northern part of the land plunged as all the Gods, deities and Rishis (sages) assembled on the Kailash Mountain. Thus Shiva sent one of the Saptarishis, Agastya Muni, (also known as Agathiar or Agastyar) to the southern India in order to balance the land. Lord Shiva put Kaveri in the Kamandalu, a copper pot for carrying sacred water, of Sage Agastya and sent him to the Podhigai ranges.
During this period, the demon Surapaduman threatened the Hindu deities and also frightened the king of gods, Lord Indra, who escaped to a holy garden created by Shiva. But as Lord Varuna, the god of wind, was also terrorized by Surapaduman, there was a lack of rain and Indra`s garden started to dry up. Then Narada informed the king of gods that Kaveri River was inside the Kamandalu of Agastya Muni. Subsequently Lord Indra prayed to Lord Ganesha, the remover of obstacles, for help.
By this time, Sage Agastya had traveled to the Kodagu mountains (in Coorg). Lord Ganesha then took the appearance of a crow and landed on the edge of the kamandalu, while Agastya Muni was involved in meditation. The sage then realized this and raised his hands to remove the crow. But while departing, the divine crow tipped and knocked over the sacred pot. Thus River Kaveri was poured on the ground and she started to flow in to the land, which is now known as Talakaveri (Talacauvery).
The divine crow then took the appearance of a small boy. The holy sage realized that the small boy was playing some trick. Agastya Muni clenched his fists and tried to strike on the head of the boy. The small boy then ran away and the sage followed him. Eventually the boy took the form of Lord Ganesha and appeared in front of Agastya. The sage became astounded to discover that the boy was Ganesha. As penance, Agastya Muni started hit his own head with his clenched fists. The Lord then stopped him and blessed the sage with wisdom.
There is another version of this legend, which states that Kaveri was originally known as Ponni. Once she disrespected Agastya Muni, who trapped Ponni in his sacred kamandalu as punishment for her behaviour. Consequently, Narada prayed to Lord Ganesha for help. Thus the Lord took the appearance of a divine crow and knocked over the pot. It poured the river Ponni on the ground, who immediately started flowing. After this event, Ponni was known as Kaveri (Cauvery).