Determining the spatial variation of accelerated electron spectra in solar flares