Every railroad corporation, and any lessee or other person in possession of its road, shall, before the lines of its road are opened for use, and so soon as it has acquired the right of way for its roadway, erect and thereafter maintain fences on the sides of its road of height and strength sufficient to prevent cattle, horses, sheep and hogs from going upon its road from the adjacent lands, with farm crossings and openings with gates therein at such farm crossings whenever and wherever reasonably necessary for the use of the owners and occupants of the adjoining lands, and shall construct where not already done, and hereafter maintain, cattle-guards at all road crossings, suitable and sufficient to prevent cattle, horses, sheep and hogs from going upon its railroad. So long as such fences and cattle-guards are not made, or are not in good repair, the corporation, its lessee or other person in possession of its road, shall be liable for all damages done by their agents or engines or cars to any domestic animals thereon. When made and in good repair, they shall not be liable for any such damages, unless negligently or wilfully done. A sufficient post and wire fence of requisite height shall be deemed a lawful fence within the provisions of this section, but barbed wire shall not be used in its construction.
No railroad need be fenced, when not necessary to prevent horses, cattle, sheep and hogs from going upon its track from the adjoining lands. Every adjoining land owner, who, or whose grantor, has received compensation for fencing the line of land taken for a railroad, and has agreed to build and maintain a lawful fence along such line, shall build and maintain such fence. If such owner, his heir or assign shall not build such fence, or if built, shall neglect to maintain the same during the period of thirty days after he has been notified so to do by the railroad corporation, such corporation shall thereafter build and maintain such fence, and may recover of the person neglecting to build and maintain it the expense thereof. And when such railroad shall cross timbered or forest lands, the company shall construct and maintain suitable and sufficient crossings, whenever and wherever reasonably necessary to enable the respective owners of said lands to transport logs, timber and lumber for manufacture or sale, or for banking on any stream, to be floated or driven down the same. In case of any neglect or dispute the supreme court may by mandamus or other appropriate proceedings, compel the same, and also fix the point or location of any such crossing.
As used in this section, the term "farm crossings" shall mean at-grade rail crossings that are utilized primarily as access to and from adjoining property which is actively used for farming or agricultural purposes by the owner or by the tenant of such property.
N.Y. R.R. Law § 52