Filter Twitter Stream by Geolocation

So far I’ve been able to access the public twitter stream using the Twitter4j library, and filter the results by geolocation. I am currently testing it with a bounding box for Metro Vancouver, but for the final version I will probably only filter results for Vancouver. The tweets appear in real time within the error console, displaying the persons name, username, tweet content and longitude and latitude value.

Streaming tweets

In order to manage the large amount of data I’m receiving, I’ve used the table function to create a new CSV file that saves all of the twitter data to an Excel spreadsheet.

excel spreadsheet

From what I’ve read, there are two types of tweet streams that Twitter offers. The Firehose is the complete stream of live tweets, and the garden hose provides 10% of realtime data. I’m only allowed access to the garden hose, and even though this is a small sample of total data, I think there are enough tweets available for the scope of this project.

Using Processing 2.2.1, the code below accesses the live Twitter stream. The data is saved to a spreadsheet and displayed in the console.


Leave a Reply