For many applications, it is important to measure the local work function of a surface with high lateral resolution. Low-energy electron microscopy is regularly employed to this end since it is, in principle, very well suited as it combines high-resolution imaging with high sensitivity to local electrostatic potentials. For surfaces with areas of different work function, however, lateral electrostatic fields inevitably associated with work function discontinuities deflect the low-energy electrons and thereby cause artifacts near these discontinuities. We use ray-tracing simulations to show that these artifacts extend over hundreds of nanometers and cause an overestimation of the true work function difference near the discontinuity by a factor of 1.6 if the standard image analysis methods are used. We demonstrate on a mixed-terminated strontium titanate surface that comparing LEEM data with detailed ray-tracing simulations leads to much a more robust estimate of the work function difference.