A nematic liquid crystal in contact with a grating surface possessing an alternating stripe pattern of locally homeotropic and planar anchoring is studied within the Frank-Oseen model. The combination of both chemical and geometrical surface pattern leads to rich phase diagrams, involving a homeotropic, a planar, and a tilted nematic texture. The effect of the groove depth and the anchoring strengths on the location and the order of phase transitions between different nematic textures is studied. A zenithally bistable nematic device is investigated by confining a nematic liquid crystal between the patterned grating surface and a flat substrate with strong homeotropic anchoring.