Disgruntled Stuart Cook deliberately broke wind three times during the search after being caught with cannabis.
Depute fiscal Alan Townsend said police attended at the Lang Stracht in Aberdeen following a report of a collision and saw the 28-year-old standing next to a vehicle talking to the driver of another vehicle.
He said: “Officers approached him and smelled cannabis.”
Cook became “irate” when he was handcuffed and began shouting at officers.
A search was carried out of Cook and the vehicle and a small amount of cannabis was discovered.
Cook continued to act in the same way as he was driven to Kittybrewster police station.
He “screamed expletives” and “puffed out his chest towards officers”, the court heard.
At the station he was strip searched and told to bend over.
At a previous hearing, depute fiscal Lucy Simpson described what happened next.
She said he “deliberately farted in the direction of the officer three times, stating, ‘how do you
Cook, of Stonehaven, Aberdeenshire, previously pleaded guilty to possession of cannabis and to behaving in a threatening or abusive manner by shouting and screaming aggressively, displaying aggressive body language, making a lewd remark towards police and “intentionally flatulating” in the direction of police.
Defence solicitor Laura Gracie said her client had been involved in a minor traffic accident. She said: “He had been smoking a cannabis joint at the time and felt police overreacted in the way they dealt
“He became increasingly upset with them and acted in the manner libelled.”
Sheriff Ian Wallace ordered Cook to carry out 75 hours of unpaid work.
He was admonished for the drug possession offence.