Dr. John Lyman, 62, who directed studies of the ocean for three agencies in the course of 20 years with the federal government, died of cancer Thursday at his home in Chapel Hill, N.C.

At the time of his death, Dr. Lyman was professor emeritus of environmental chemistry at the University of North Carolina, where he had moved in 1968 to head the school's office of marine sciences.

He began his career in Washington in 1946, when he became director of oceanography for the Navy Hydrographic Office. He later became director of oceanography at the National Science Foundation and then chief adviser for oceanographic research at the Bureau of Commercial Fisheries. Before going to Chapel Hill in 1968, he worked for the Office of Naval Research.

Born in Berkeley, Calif., Dr. Lyman did undergraduate work there and received his master's and doctorate degress from Scripps Institution of Oceanography, part of the University of California in Los Angeles. He served in the Navy in World War II.

He was a member of the Washington Academy of Sciences and the American Association for the Advancement of Science.

Survivors include his wife, Mitchell Forrest, of the home in Chapel Hill, N.C. and two sons, John and Richard, of Chapel Hill.

The family suggests that expressions of sympathy be in the form of contributions to the American Cancer Society.