Section 4. The department of highways, county commissioners, and the officers having charge of highways in any city or town may construct ditches or drains for the purpose of properly draining any highway, and may carry water away from any highway and over or through any land as they may deem necessary for public convenience or for the proper care or construction of such highway, and may purchase or take by eminent domain under chapter seventy-nine, on behalf of the commonwealth, county, city or town, such land or interest therein as may be necessary therefor. Such ditches and drains shall be under the control of said officials, who may enter upon any land for the purpose of constructing, repairing or maintaining the same; but they shall not enter upon or construct any ditches, drains or other works or lay any conduits or pipes or discharge any water within the location of any railroad corporation, except at such time and in such manner as they may agree upon with such corporation, or, in case of failure so to agree, as may be approved by the department of telecommunications and energy. The owner or occupant of land through which any ditch or drain has been constructed under this section may, after securing a permit from the officers having control of the ditch or drain, construct and maintain a bridge over the same. The damages sustained by any person in his property by takings or other acts herein authorized may be recovered under chapter seventy-nine. The department, board or officers who have taken an easement under this section may discontinue or abandon the same by filing for record in the registry of deeds a suitable instrument.