Urbanization transforms landscapes from natural ecosystems to configurations of impervious surfaces and green spaces, leading to urban heat island effects that impact health and ecosystem sustainability. This study in Xiamen City, China, categorizes urban areas into functional zones, employs Random Forest and Stepwise Regression models to assess thermal differences, and proposes optimization measures for the building–green space landscape. The optimization involves altering the characterization of the building–green space landscape pattern. Results indicate: (1) due to the spatial heterogeneity of the building–green space landscape pattern in different functional zones, the surface temperature also shows strong spatial heterogeneity in different functional zones; (2) different optimization measures for the building–green space pattern are needed for different functional zones; taking the urban residential zone as an example, the Normalized Difference Vegetation Index (NDVI) in the hot spot area can be adjusted according to the value range of the cold spot area; (3) considering the solar radiation process, Sun View Factor (SunVF) plays an important role in indicating the change in surface temperature in the commercial service area, and as SunVF increases, the surface temperature of the functional zone tends to rise. This research offers insights into urban thermal environment improvement and landscape pattern optimization.