An individual's risk of infection from an infectious agent can depend on both the individual's own risk and protective factors and those of individuals in the same community. We hypothesize that an individual's exposure to an infectious agent is associated with the risks of infection of those living nearby, whether their risks are modified by pharmaceutical interventions or by other factors, because of the potential for transmission from them. For example, unvaccinated individuals living in a highly vaccinated community can benefit from indirect protection, or living near more children in a typhoid-endemic region (where children are at highest risk) might result in more exposure to typhoid. We tested this hypothesis using data from a cluster-randomized typhoid vaccine trial. We first estimated each individual's relative risk of confirmed typhoid outcome using their vaccination status and age. We defined a new covariate, potential exposure, to be the sum of the relative risks of all who live within 100 m of each person. We found that potential exposure was significantly associated with an individual's typhoid outcome, and adjusting for potential exposure affected estimates of vaccine efficacy. We suggest that it is useful and feasible to adjust for spatially heterogeneous distributions of individual-level risk factors, but further work is required to develop and test such approaches.