In every grant to construct street railroads, the right to grade, sewer, pave, macadamize, or otherwise improve, alter, or repair the streets or highways, is reserved to the city and cannot be alienated or impaired. The work shall be done so as to obstruct the railroad as little as possible, and if required, the street railway corporation shall shift its rails so as to avoid the obstructions made thereby.