An eight-sided prism sample, obtained from a hot-rolled AZ31 magnesium alloy sheet, was compressed at room temperature along the transverse direction to investigate the influence of local strain on twinning behavior using electron backscatter diffraction (EBSD) measurements. The octagonal surface of the sample was divided into distinct regions based on hardness distribution and metallographic observations. The EBSD maps of different areas show significant variations, suggesting that these areas experienced different local strain conditions. The EBSD measurements provided detailed data from three distinct regions, with the strain state known in two regions and uncertain in the third. The combined analysis of the Schmid factor (SF) and the strain compatibility factor (m') was employed to study twin variant selection. The comparison of twinning behavior in different regions showed that the strain compatibility factor offered a more comprehensive explanation for the observed twinning pattern in the region with local shear strain.