A semianalytic formula for calculating the magnetic field produced by a circular coil with rectangular cross section in air is proposed. In the formula, the coil is approximated as a series of circular rings with small cross sectional area, of which the current density can be considered as constant. In order to simplify the calculation of the magnetic field, the translation transformation and scaling transformation are introduced. Furthermore, all the possible singular cases, in the expressions, are treated properly. Therefore, with the help of one-dimensional Gauss-Legendre quadrature, the magnetic field at any points in space produced by current-carrying circular coil, especially inside the coil, can be calculated very easily.