This paper is concerned with the transverse structure of the ballooning instability in a two-dimensionally inhomogeneous model of the magnetosphere, which takes into account inhomogeneity both across the magnetic shells and along the field lines. According to the previous studies, the ballooning instability can develop at steep fall of the plasma pressure from the Earth. In this paper, the region of negative plasma pressure gradient is assumed to be sharply localized across the magnetic shells. It causes the localization of the unstable perturbation in the same direction. In this region, the perturbation has a resonator-like structure, where only modes with discrete set of the growth rate values can exist. The azimuthal wave number of the unstable mode must exceed some critical value, which is determined by the width of the localization region.