Porous rocks, subjected to compressive stress, often undergo mechanical compaction via grain crushing and rearrangement, and chemical compaction via pressure solution. The compaction leads to irreversible volume reduction that spontaneously localizes into elongated features under some conditions. This work presents an analytical solution for the stress around a 2D compaction band (CB), using the "transformation problem" introduced by Eshelby (1957). The analytical solution is shown to agree with results from a new version of a Spring Network Model for simulating mechanical and chemical compaction. The similarity of the stress fields around CBs and edge-dislocations is shown and is such that one may describe CBs as anti-dislocations.