Automatic detection for targets with complex shape in high-resolution remote sensing images is a challenging task. In this letter, we propose a new detection framework based on spatial sparse coding bag-of-words (BOW) (SSCBOW) model to solve this problem. Specifically, after selecting a processing unit by the sliding window and extracting features, a new spatial mapping strategy is used to encode the geometric information, which not only represents the relative position of the parts of a target but also has the ability to handle rotation variations. Moreover, instead of K-means for visual-word encoding in the traditional BOW model, sparse coding is introduced to achieve a much lower reconstruction error. Finally, the SSCBOW representation is combined with linear support vector machine for target detection. The experimental results demonstrate the precision and robustness of our detection method based on the SSCBOW model.