The determination of carbon dioxide (CO2) emissions from heavy-duty diesel trucks (HDTs) is important for the development of traffic emission reduction strategies. This study quantified the CO2 emissions from 5,996 HDTs on different road types using a bottom-up approach combined with the application of the International Vehicle Emissions (IVE) model based on 1.24 million trajectory points. A correlation analysis was conducted on the hourly traffic flow, driving mileage, speed, and CO2 emissions of HDTs in the urban area of Kunming, China. The traditional emission intensity allocation method was improved by establishing a high-resolution (1 × 1 km) emission inventory using trajectory points and the road network density. The results indicated that higher driving speeds can reduce CO2 emissions, but HDTs typically maintain speeds of 40–60 km/h, with emission coefficients around 500 kg/km; HDTs complying with China III standards are significant contributors to CO2 emissions; Regional CO2 emissions from HDTs are highly influenced by traffic flow and driving distances; Vehicle restriction policies contribute to increased nighttime emissions; A pollution spatial allocation method based on trajectory point density and road network density better reflects the regional spatial distribution of CO2 emissions from HDTs; CO2 spatial distribution is predominantly concentrated in the southeast of urban areas, primarily influenced by urban industrial layout.