Beginning with the New York and Harlem Line in the 1840 's , trains hastened a shift from subsistence to commodity agriculture , with farmers shipping large quantities of milk and other goods to New York City .