The approximation of stochastic partial differential equations and applications in nonlinear filtering