Abstract The ability to calculate the seismogram of an earthquake at a local or regional scale is critical but challenging for many seismological studies because detailed knowledge about the 3D heterogeneities in the Earth’s subsurface, although essential, is often insufficient. Here, we present an application of compressed sensing technology that can help predict the seismograms of earthquakes at any position using data from past events randomly distributed in the same area in Jinggu County, Yunnan, China. This first data-driven approach for calculating seismograms generates a large dataset in 3D with a volume encompassing an active fault zone. The input number of earthquakes comprises only 1.27% of the total output events. We use the output data to create a database intended to find the best-matching waveform of a new event by applying an earthquake search engine, which instantly reveals the hypocenter and focal-mechanism solution.