As for the collecting data. It can be done, if the right sensors are used. For example a movement or magnet sensor to trigger a traffic light or weight sensors to measure how full train cars are. If a city has fare gates, those might be used to count usage as well.
Also open source code for public infrastructure would go a long way to help with that.