In this work, we investigate the effects of nanogrooves on heterogeneous ice nucleation (HIN) through molecular dynamics simulations. It is found that nanogrooves on a surface significantly alter the ice nucleation rate by more than 2 orders of magnitude. Depending on the width of the grooves, the nucleation rate can be enhanced or impeded compared with that on flat surfaces. For relatively large grooves, ice nucleation enhancement is observed when the effective groove width is a multiple of the ice lattice constant, for which ice crystal nucleus forms in the groove. For narrow grooves, strong confinements lead to the formation of solid-like layered structures, which may or may not enhance ice nucleation, depending on their structural match with ice crystal. The findings in this work provide critical information for surface designs in controlling HIN.