CO line ratios in molecular clouds: the impact of environment