Optimizing Evacuation Routes using Real-Time Traffic Information
During disasters, search and rescue teams must be able to search for and get to survivors as fast as possible (in terms of travel time and distance). Current GIS and navigation systems allow responders to calculate travel time and distance between origin and destination and propose an optimal route to the destination. However, many of the current platforms do not rely on real-time data (e.g. road closures, damaged roads etc.) and can produce inaccurate or inefficient results. This project will leverage social media, news feeds and other datasets (e.g. Waze, Here.com) to identify real time road closures or damaged roads, power outages and other blocked routes that may affect traffic lights, travel time, travel safety and more.The system should allow the user (the public or rescue teams) to search for any of these conditions and identify if and where they exist in a specific location (street, neighborhood, city etc.)
Tweepy library is used to grab live tweets about traffic. Beforehand, it was manually searched to determine which Twitter users post mainly about traffic and road conditions, in each city of the most flooded ones in the US. A data frame with these Twitter usernames, and the corresponding cities was created, for the user (first respondent) to select from. Next step goal: make this data frame inclusive to every city in the US; specially the ones who face natural disasters more frequently than others.
We decided to apply the question to two different types of natural disasters: Fire and flood. Using the GetOldTweets3 library designed by Jefferson Henrique, a former General Assembly DSI student, and then debugged by, presumably, the Python developers, I was able to gather a good chunk of relevant and irrelevant data with respect to identifying road closures in the midst of the “Campfire” that raged in California from mid-February until the end of November. First, I harevsted tweets from the State Fire Department and the State Dept. of Transportation in the same time period as the subject fire. I found that the results were adequate but didn’t appear to have the depth for whcih we were aiming. Then I found I could do a simple word query search and that got me a nicer result insofar as I could gather tweets from everywhere that had to do with road closures. the keyword/query search appears to be the best to employ for this endeavor. After that, I ran it through a mask, thanks to Haya Toumy, my colleague, otherwise I would have been wrestling with the problem for days. Like this I was able to see if the sting in each tweet contained ‘road, closed, closure.’ I put the results into a dataframe.
In my part I had no real model. I used word2vec but eventually I would like to create a model that would effortlessly decide what’s relevant in order to make the speed faster and take only specific sentences that are neccessary.
No modeling was needed in this process. Search through collected live tweets’ text to find the entered street name by user; handling for any letter case entered by user to be accepted.
I used a CountVectorizer coupled with a Logistic Regression model(Logistic becasue we are classifying (thanks for the reminder Haya.) I found that it was effortlessly accurate with the y target, 99 percent accuracy. I could increase the variable target components and aggregate them to produce a finer picture of whether for instance someone needs help or if a road blockage is simply being communicated. Ideally, this would just pop up where ever your position is on the globe via geolocation on your phone. This was a fascinating project, and I feel enriched to have applied and wrestled with the things I’ve learned thus far for the sake of the preservation of life.
In order to run our final pre-deployed project, you need to do a couple of steps:
- Fork this git repo into your own.
- Place it somewhere
git clone repo
- Go into it
- Create an enviornment
python -m venv venv
- Install requirements
pip install -r requirements.txt
- Add file KeysAPI
- Inside app/KeysAPI.py
newsapi = # Your key here_id = # Your key here_code = # Your key tweet_1 = # Your key tweet_2 = # Your key tweet_3 = # Your key tweet_4 = # Your key
- Execute it
- Then go to the port it specifies; most likey will be port: http://127.0.0.1:5000
A function that takes a user input for a street name, and returns 20 most recent tweets about that road condition and all its intersections. The function searches through traffic tweets from Houston, TX by default, but user can choose another city from the provided ones. All done in one line, all in small letters, for the ease and quick of use.
- Jupyter Notebook