When Hurricane Florence struck North Carolina last fall, floodwaters swamped vast stretches of farmland and graphically demonstrated a threat this part of the country is particularly vulnerable to: massive volumes of animal waste overflowing into waterways.

North Carolina has one of the world’s largest concentrations of industrial pig farms, with more than 2,000 operations involving a total of about 10 million hogs. Most store manure in open-air pits called “lagoons,” and when these overflow they can contaminate waterways with pathogens, pharmaceuticals and nutrients that pose serious pollution and health risks. Environmental watchdogs are on the frontlines of monitoring such overflow events and tracking the damage, both in North Carolina and from other livestock and poultry farms around the country. But first they need to actually find the industrial farms—many of which are not legally required to make their locations publicly available. This forces would-be monitors to manually pick out farms from satellite and aerial imagery—a task that can take months (or, in the case of one state agency in Iowa, longer than three years) to complete.

But researchers at Stanford University have found a way to pinpoint these farms in a fraction of that time, by using machine learning to train a computer model to identify them. “We realized this was exactly the kind of place where we could leverage the really rapid advancements in computer vision,” says Stanford law professor Daniel Ho, who co-authored a new paper on the technique, published in Nature Sustainability this week.

Ho and his team focused on farms called concentrated animal feeding operations (CAFOs). These are defined as containing more than 1,000 beef cattle, 2,500 pigs or 125,000 broiler chickens for more than 45 days. CAFOs across the country churn out roughly 335 billion tons of manure each year—but they are not required to treat it in the same way that jurisdictions and homes must treat human waste. “When a single CAFO can produce as much manure [fecal waste] as a medium-sized city,” Ho says, “how do we ensure that the waterways of the United States are protected?”

The federal government does regulate effluent discharge from CAFOs—up to a point. The Environmental Protection Agency requires these operations to obtain discharge permits, which limit the quantity of waste and areas where CAFOs can legally discharge it, but these limits only apply to operations that actively release effluent into waterways.

Some farmers say such rules are enough to protect waterways. “The EPA’s charge is to protect the waters of the U.S. to make sure they are safe for drinking and recreating in,” says Paul Bredwell, vice president of environmental protection with the U.S. Poultry and Egg Association in Tucker, Ga. “If the EPA is satisfied with their regulations, then certainly we feel as though, if we adhere to those regulations, then [farmers] are going to do their job in protecting the environment.”

But some environmental groups argue that the EPA standards are too lax, in part because they do not account for unforeseen overflow events during storms like Hurricane Florence. This has motivated these groups to seek more stringent regulation and oversight, Ho says.

The first step is locating the farms. To train a computer model to help, Ho and his team compiled 24,440 publicly available satellite images from a study area across North Carolina. A crew of students helped the team manually sift through these photos for the hallmark features of CAFOs, such as clusters of long, narrow buildings and, in the case of hog farms, open-air lagoons (many North Carolina poultry farms do not have such lagoons because they store waste indoors). The team also identified similar-looking facilities the computer might mistake for CAFOs. Examples included airplane hangars, which are also often clustered together but tend to sit amid concrete runways rather than agricultural land, Ho explains. Once the researchers fully trained the model to distinguish CAFOs, the team demonstrated that computer vision could successfully identify 95 percent of the CAFOs that a manual survey had found—but in less than one tenth the time.

“That’s something we would strongly considering investing in,” say Soren Rundquist, director of spatial analysis at the nonprofit Environmental Working Group (EWG) in Washington, D.C. Rundquist contributed imagery and guidance to Ho’s team but was not an author on the new study. He has conducted extensive manual surveys of CAFOs for his work with EWG, and knows firsthand how time-consuming that task can be. “Allowing a computer to guide you where to look and manually validating the computer’s results will definitely help streamline the process,” he says. Rundquist also notes this will be especially valuable as CAFOs continue to rapidly proliferate, creating a moving target for environmental groups’ monitoring efforts.

Still, Rundquist notes this technology is relatively young and will need fine-tuning to capture the nuances of different CAFO designs, especially in other parts of the country. For example, hog CAFOs in the Midwest generally lack the outdoor manure lagoons typical of those in North Carolina, so the model would need to undergo region-specific training. Rundquist also notes that most nonprofit environmental organizations would probably not have the capacity to deploy the technology on their own, at least in the short term. The software requires a level of familiarity with coding that academic groups may have, but nonprofits may not. They would likely need to work together, at least in the technology’s initial phase, Ho says.

At this early stage the method also would not completely eliminate the human element in identifying farm locations. People would still need to manually confirm the accuracy of the computer model’s results. But the program does offer a helpful launching point to speed up that process.

“We view it as a first step,” Ho says, “to show how machine learning can be a viable and cost-effective complement to human monitoring efforts.”