Astronomers reported that there could be as many as 40 billion habitable Earth-size planets in the galaxy, based on a new analysis of data fromNASA’s Kepler spacecraft.

One out of every five sunlike stars in the galaxy has a planet the size of Earth circling it in the Goldilocks zone — not too hot, not too cold — where surface temperatures should be compatible with liquid water, according to a herculean three-year calculation based on data from the Kepler spacecraft by Erik Petigura, a graduate student at the University of California, Berkeley.

Mr. Petigura’s analysis represents a major step toward the main goal of the Kepler mission, which was to measure what fraction of sunlike stars in the galaxy have Earth-size planets. Sometimes called eta-Earth, it is an important factor in the so-called Drake equation used to estimate the number of intelligent civilizations in the universe. Mr. Petigura’s paper, published Monday in the journal Proceedings of the National Academy of Sciences, puts another smiley face on a cosmos that has gotten increasingly friendly and fecund-looking over the last 20 years.