This paper models the local and cross-city transmissions of the novel coronavirus in China between January 19 and February 29 in 2020. We examine the role of various socioeconomic mediating factors, including public health measures that encourage social distancing in local communities. Weather characteristics two weeks ago are used as instrumental variables for causal inference. Stringent quarantine, city lockdown, and local public health measures imposed since late January significantly decreased the virus transmission rate. The virus spread was contained by the middle of February. Population outflow from the outbreak source region posed a higher risk to the destination regions than other factors including geographic proximity and similarity in economic conditions. We quantify the effects of different public health measures in reducing the number of infections through counterfactual analyses. Over 1.4 million infections and 56,000 deaths could have been avoided as a result of the national and provincial public health measures imposed in late January in China.