A state of emergency has been declared in New York after a heavy downpour brought flash flooding to the US city.