A method for geosteering, the method comprising: accessing typelog reference data respectively associated with a plurality of reference wells in a geological vicinity of a well being drilled; using the typelog reference data, performing a typelog alignment for the plurality of reference wells using multi-stage optimization to generate an aligned geosteering depth log; using the aligned geosteering depth log, determining a stratigraphic depth of a bottom-hole assembly (BHA) in the well during drilling; and using the aligned geosteering depth log, steering the drilling of the well based on the stratigraphic depth towards a predetermined target, wherein performing the typelog alignment for the plurality of 2. reference wells using multi-stage optimization further comprises: determining a start depth and an end depth for the typelog alignment; preprocessing the typelog reference data, including a rank transformation and multistage smoothing; performing a multistage iterative optimization including successive alignment through multiple stages of smoothed data; when results of the multistage iterative optimization are not acceptable, adjust at least one of the start depth, the end depth, and a current alignment function; and when results of the multistage iterative optimization are acceptable, outputting the aligned geosteering depth log, including aligned depth markers between the start depth and the end depth. accessing typelog reference data respectively associated with a plurality of reference wells in a geological vicinity of a well being drilled; using the typelog reference data, performing a typelog alignment for the plurality of reference wells using multi-stage optimization to generate an aligned geosteering depth log; using the aligned geosteering depth log, determining a stratigraphic depth of a bottom-hole assembly (BHA) in the well during drilling; and using the aligned geosteering depth log, steering the drilling of the well based on the stratigraphic depth towards a predetermined target, wherein performing the typelog alignment for the plurality of 2. reference wells using multi-stage optimization further comprises: determining a start depth and an end depth for the typelog alignment; preprocessing the typelog reference data, including a rank transformation and multistage smoothing; performing a multistage iterative optimization including successive alignment through multiple stages of smoothed data; when results of the multistage iterative optimization are not acceptable, adjust at least one of the start depth, the end depth, and a current alignment function; and when results of the multistage iterative optimization are acceptable, outputting the aligned geosteering depth log, including aligned depth markers between the start depth and the end depth. determining a start depth and an end depth for the typelog alignment; preprocessing the typelog reference data, including a rank transformation and multistage smoothing; performing a multistage iterative optimization including successive alignment through multiple stages of smoothed data; when results of the multistage iterative optimization are not acceptable, adjust at least one of the start depth, the end depth, and a current alignment function; and when results of the multistage iterative optimization are acceptable, outputting the aligned geosteering depth log, including aligned depth markers between the start depth and the end depth. <EOS>