In Intelligent Transportation Systems (ITS), controlling the traffic flow of a region in a city is the major challenge. Particularly, allocation of the trafficfree route to the taxi drivers during peak hours is one of the challenges to control the traffic flow. So, in this paper, the route between the taxi driver and pickup location or hotspot with the spatial-temporal dependencies is optimized. Initially, the hotspots in a region are clustered using the density-based spatial clustering of applications with noise (DBSCAN) algorithm to find the hot spots at the peak hours in an urban area. Then, the optimal route is allocated to the taxi driver to pick up the customer in the hotspot. Before allocating the optimal route, each route between the taxi driver and the hot spot is mapped to the number of taxi drivers. Among the map function, the optimal map is selected using the rain optimization algorithm (ROA). If more than one map function is obtained as the optimal solution, the map between the route and the taxi driver who has done the least number of trips in the day is chosen as the final solution This optimal route selection leads to control of the traffic flow at peak hours. Evaluation of the approach depicts that the proposed traffic flow control scheme reduces traveling time, waiting time, fuel consumption, and emission.