The thermometer is located in a white enclosure with slats on the side that block the sun, but allow air to flow through. The structure is elevated several feet from the ground and is usually set over an open, grassy surface. All these steps are taken to minimize the affect of the sun and weather. For example, thermometers displayed in direct sunlight will display a much higher reading than the actual air temperature. And thermometers that become wet may read a lower temperature because of evaporational cooling. The reason the housing is painted white is that white paint reflects excess solar energy that would skew the thermometer's reading. It's the same reasoning when it comes to the grassy surface. Other materials like stone would radiate excess solar energy up to the thermometer, skewing its readings. Grass does not radiate nearly as much energy. And the elevated platform makes excess radiation from the ground even less of a factor.
Official weather reporting stations (including the thermometers that give us our daily readings) are often located on the grounds of airports, because the data collected can be valuable for pilots.