The principles and methods of geostatistcs are introduced. Based on sampling data from the city river, the NH4+-N content is used as the parameter of water quality to analyze the water pollution. With the variogram of geostatistcs, the spatial variation of the NH4+-N content is shown intuitively. By using the Kringing, the special distribution of the NH4+-N is simulated. With MATLAB language, the Contour and three-dimensional map of the spatial distribution of the NH4+-N is obtained. The research of geostatistics on water quality provides a theoretical basis for protecting the water environment and controlling the water pollution.