Five NYPD pilots were so ­angry at their supervisor that they used a $4 million, federally funded spy plane to fly a route shaped like a giant penis, The Post has learned.

Inspector James Coan, head of the Aviation Unit, learned of the phallic airborne artwork from his minions, who discovered the lewd pattern on the department’s flight-tracking software, sources said.

He alerted NYPD brass, and the pilots were disciplined following an internal hearing — with two getting bounced from the unit.

The raunchy route came amid a feud between the pilots and Coan over whether the single-engine Cessna was safe to fly over open water — which is why the feds paid for it in the first place, according to the sources.

In July 2017, pilots were told to fly at low altitudes over open water 25 miles offshore so they could scan ships for radiological weapons.

“If that prop [propeller plane] goes, it’s over. You’re going to crash into the ocean,” a source said they warned their boss, Coan.

“They wouldn’t have enough glide time to get back to land at that altitude. It was like a suicide mission.”

The low-altitude flights also left them out of radar and radio range, sources added.

The pilots’ pushback intensified this past March, when Coan ordered them to make the runs more frequently, sources said.

Amid their protests, five flyboys took the plane up and flew the penis-shaped route. Supervisors on the ground saw the phallic flight path while tracking the plane and raised the ­issue with Coan.

In total, a dozen pilots have questioned the wisdom of flying a single-engine plane so far out over open water, sources said.

Eight of them — including the five penis-drawing pilots — were stripped of their flight gear and made to clean plane hangars and wash Coan’s department car, according to sources.

“Any of the people who complained about the mission — they got the s–t end of the stick,” a source said. “They had to do all these menial tasks outside their job description, including washing his car.”

NYPD pilots average more than $100,000 a year in pay, according to records posted on SeeThroughNY.net. “They’re wasting a fortune in training and expertise,” a source added.

By May, the NYPD had agreed to cease the offshore counterterror missions altogether until it met with the union representing pilots, but the meeting has yet to happen, sources said.

The plane’s last flight, according to tracking service Flight Aware, was on July 5, after it shuttled Mayor Bill de Blasio between his vacation in Canada and a Big Apple police memorial event.

Police Commissioner James O’Neill has defended using the plane for other than counterterrorism.

Last year, he rode the bird to the funeral for then-Chief of Detectives Robert Boyce’s mother, Dolores, and he admitted taking it to western New York for the July 8 funeral of a state trooper.

That flight does not appear on Flight Aware records, and the NYPD has refused to release the plane’s flight logs to The Post.

FEMA, which issued the grant used to buy the plane, has said it is looking into whether the NYPD misused the Cessna.

The NYPD did not respond to a request for comment Tuesday.