Forward modeling of gravity fields in spherical coordinates