Trevor Bickford - who was also charged with two counts of attempted assault - travelled to NYC by train from Maine before the attack, police said.
US media reported his family recently told the FBI they feared he was being radicalised by Islamist extremists.
Police Commissioner Keechant Sewell said the attack was "unprovoked".
The three officers - one of whom suffered a fractured skull after being struck by the machete - were all released from hospital on Sunday.
Mr Bickford is believed by investigators to have travelled to the city on 29 December after withdrawing thousands of dollars in cash from his bank account and purchasing the knife later used in the attack.
He allegedly launched his attack shortly before 22:00 local time on Saturday near an area that had been set up for New Year's Eve celebrations, Ms Sewell said.
During the attack he attempted to strike police over the head with his weapon, before one of the officers fired their weapon and hit him in the shoulder, officials said.
Mr Bickford remains in hospital under police custody because of the injuries sustained in the attack.
Photo Getty Images