We propose an optimal-level distributed transform for wavelet-based spatiotemporal data compression in wireless sensor networks. Although distributed wavelet processing can efficiently decrease the amount of sensory data, it introduces additional communication overhead as the sensory data needs to be exchanged in order to calculate the wavelet coefficients. This tradeoff is explored in this paper with the optimal transforming level of wavelet transform. By employing a ring topology, our scheme is capable of supporting a broad scope of wavelets rather than specific ones, and the “border effect” generally encountered by wavelet-based schemes is also eliminated naturally. Furthermore, the scheme can simultaneously explore the spatial and temporal correlations among the sensory data. For data compression in wireless sensor networks, in addition to minimizing energy and consumption, it is also important to consider the delay and the quality of reconstructed sensory data, which is measured by the ratio of signal to noise ( PSNR ). We capture this with energy × delay / P S N R metric and using it to evaluate the performance of the proposed scheme. Theoretically and experimentally, we conclude that the proposed algorithm can effectively explore the spatial and temporal correlation in the sensory data and provide significant reduction in energy and delay cost while still preserving high PSNR compared to other schemes.