Even if the law sides with the railroad, the farmer will pay the railroad to control the sparks.
Suppose that it costs two thousand dollars to control the sparks, the lost crops are worth only one thousand, and the law sides with the farmer.