Wireless sensor networks (WSNs) are highly resource constrained in terms of power supply, memory capacity, communication bandwidth, and processor performance. Compression of sampling, sensor data, and communications can significantly improve the efficiency of utilization of three of these resources, namely, power supply, memory and bandwidth. Recently, there have been a large number of proposals describing compression algorithms for WSNs. These proposals are diverse and involve different compression approaches. It is high time that these individual efforts are put into perspective and a more holistic view taken. In this article, we take a step in that direction by presenting a survey of the literature in the area of compression and compression frameworks in WSNs. A comparative study of the various approaches is also provided. In addition, open research issues, challenges and future research directions are highlighted.