The global Langlands-Kottwitz method seeks to express Frobenius-Hecke traces on the cohomology of Shimura varieties in terms of (twisted) orbital integrals; the latter are central objects in local harmonic analysis which enter the Arthur-Selberg trace formula. While this method is well studied, we present a new local analogue: a formula relating the cohomology of local Shimura varieties to twisted orbital integrals. This local formula bridges the point-counting formula for global Shimura varieties with the point-counting formula for Igusa varieties. As an application of our local formula, we propose a new approach, based on categorical Langlands, towards Rapoport's vanishing conjecture on certain twisted orbital integrals. This conjecture is itself a key ingredient in the global Langlands-Kottwitz method for a non-quasi-split prime. This is joint work with Rong Zhou.