Abstract Surface offset gathers (SOGs) are crucial for velocity updating in seismic data migration and muting the stretched waveform in shallow parts of migrated seismic data. Kirchhoff-based migration methods can output SOGs because they take every seismic trace as the input. As a result, the imaging results can be rearranged according to the offset value of the input data to obtain SOGs. However, regarding more accurate wave equation methods (such as reverse time migration, RTM), the SOGs cannot be obtained directly with a single migration calculation. Attribute migration is an easy-to-implement method to output SOGs of wave equation migration methods. It calculates the offset value of each imaging point by dividing the migration result modulated by the offset attribute with the conventional migration result. However, the division error may cause the calculation result outside the given offset value. This paper proposes a constrained least-squares inversion method for stable calculation of the RTM offset range. The method ensures that the calculated results are within the given offset range. We tested the method against the direct division and least-squares methods without constraints using the Marmousi model and a real 3D dataset. We show that the SOGs obtained by the constrained least-squares inversion attribute migration method had the same characteristics as those derived using the division-based attribute migration method, but they also had higher vertical resolution, better energy distribution, and improved lateral continuity. In a further study, we expect to develop a stable and direct method to efficiently calculate SOGs for RTM and an iterative closed loop for RTM velocity updating.