Every first or second class municipality shall have power to require railroad companies to keep flagmen and maintain lights at railroad crossings of streets and provide for the safety of persons and property; to compel them to construct, maintain, and operate gates at railroad crossings of streets when the keeping of a flagman is not sufficient protection; to compel them to raise or lower their tracks to conform to any grade which may be established by the municipality and to keep such tracks on the level with the street or highway surface, so that such tracks may be crossed at any place on such street or highway; to require them to fence their railroads and construct and repair cattle guards, viaducts, or overhead crossings, and to provide for and change the location, grade, and crossing of any railroad; all subject to the powers vested in the Public Utilities Commission.
SDCL 9-35-9