In large structure machining by gantry machine tools, the long machining duration with large temperature variation affects the machining accuracy significantly. To reduce the machining error of large structure, a method to model and compensate thermally induced positioning error considering workpiece thermal deformation is proposed. The thermal expansion of the grating scale and the thermal deformation of the workpiece are first analyzed theoretically, and a mathematical model of the positioning error and workpiece deformation error is proposed. The comprehensive model is with regard to transient temperature data of particular sensors. Compensation experiment was conducted on a three-axis gantry machine tool, and the error compensation system was applied to large structure machining to verify the effectiveness of the comprehensive error model considering workpiece thermal deformation. And the machining accuracy after compensation was greatly improved over 60%, which indicates the practicability of the proposed modeling method. It shows great potential application in large structure machining.