Posted on

TwitterWhere – Filter Tweets by Location

Inspired by a post over at Silicon Florist about following local people on Twitter, I investigated whether it was possible to follow someone in a geographic area. The closest I found was TwitterVision, which is a great idea, but doesnt exactly do what I want. So I ended up taking a few hours and developed TwitterWhere, an aggregator that watches the Twitter public timeline and geocodes what it finds. From there anyone can generate an RSS or XML feed that will pull only Tweets within a set radius around an area. Now you can have a feed of Tweets within 50 miles or Portland, or 5 miles of Manhattan,

For anyone who is interested, heres how I pulled it off

I wrote the app in Ruby on Rails, utilizing my favorite gem of all time, Graticule (geocoding and spatial search), Hpricot (parsing the public timeline on Twitter), and a couple custom geocoding libraries I already had cooked up for Unthirsty and Knitmap.

Every minute I query the Twitter public timeline XML file and the results. If a new user is entered into the system it is geocoded and any Tweets added by that user from that point inherit the coordinates. Any users with an invalid location are thrown out and not cached. I also cache geocode queries locally. Both of these measures are in place so I dont overload the geocoding services I use (especially considering I have two other fairly heavy traffic sites using geocoding services).

On the front end, feeds are not exactly generated, its more of a verification that the location someone has entered is geocodable. Once the location is verified a link is presented to the user that points to RSS or XML feeds. If this ends up getting more traffic, Ill consider using caching for each unique feed, but right now when you visit a feed URL, it is generated from the database in real time, every time.
TwitterWhere runs on my good old Dual 1.8GHz Powermac G5 at our co-location facility, using a custom compiled Apache 2.2, mod_proxy_balancer and 5 mongrels.

Okay, Im done geeking. Here are few mentions of TwitterWhere from around the web. Thanks for the write-ups!

  • Silicon Florist – TwitterWhere: Get tweets by geographic location
  • ReadWriteWeb – TwitterWhere Tracks Tweets from Any Location,
  • Wired Blog – TwitterWhere Tracks Tweets By Location

P.S. Apologies to, I didnt even think to check if the domain existed, let alone to see if there was something there! We dont exactly do the same thing ( allows you to easily update your current location on Twitter), so hopefully there isnt too much confusion.

24 Responses to TwitterWhere – Filter Tweets by Location

  1. 1 NathanaelB
    Oct 25th, 2007 at 5:16 am

    Hey, thats pretty awesome – I found 3 new local peeps just reading the feed, and now Ive set-up a Twitter account and am piping the feed from TwitterWhere into TwitterFeed into a Twitter account and have subscribed to it.

    Surprised no comments yet – weve all been talking about it / poking at it all day.


  2. 2 Patrick
    Oct 25th, 2007 at 7:12 am

    Thanks so much for doing this. Im able to find more people closer to me now.

  3. 3 adin
    Oct 26th, 2007 at 12:11 am

    I did the same thing as nathanaelB, but for central NM. Is there a more elegant method for piping the output back into twitter? Twitterfeed and RSS2Twitter are nice services, but they only update every 30 minsnot exactly the best way to get a feel for whats going on in the local area.

    It sounds like Matts next project!

  4. 4 adin
    Oct 26th, 2007 at 12:16 am

    er, for anyone interested, the twitteruser is central_nm

  5. 5 adin
    Oct 26th, 2007 at 1:14 am

    now trying using twitterbot (with mono) for faster updates. Its *much* better now, but Im getting some wierd results, like people in new jersey and japan showing up in NM. (AFAIK the public timeline lists them *not* in NM)

  6. 6 kosmar
    Oct 26th, 2007 at 1:53 am

    hi, i am thinking to use twitterwhere for a website i have in mind since some time. as i couldn’t find an emailadress at first glance, i’m just leaving this comment to give you mine. would be great to have a short chat about my idea. first question: do you use the location in the userprofile and/or tweezts that include L:foobar? tia. ma

  7. 7 Jason Falls
    Oct 26th, 2007 at 3:53 am

    Brilliant application. Kudos for the work. How about TwitterWhere mobile GPS tracking to your mobile device so it shows where you are, not where youre from? Does that exist? Just a thought.

  8. 8 Geoff
    Oct 26th, 2007 at 1:13 pm

    Hi Matt – I did this with RSS feeds from your great little app. Its brilliant. Love. Please have a look and let me know if this is ok. As I say I dont expect anyone will look but it was fun putting it together (its just wordpress with nine feeds)and I use it to find people to follow in
    Again great app, well done.

  9. 9 Trevor
    Oct 27th, 2007 at 9:37 am

    Hey Matt
    I have some ideas for a website.
    I do front end stuff but need someone to set up a database for a zip finder.
    Please contact me if you can.

  10. 10 adin
    Oct 28th, 2007 at 8:22 pm

    Im getting a *lot* of false positives, mainly from new jersey and japan (matching against zip 87120/50mi)

  11. 11 mattking
    Oct 28th, 2007 at 8:52 pm

    @adin: I did a little research and it looks like the users location that showed up in your feed was Sasebo. Im sure it meant Sasebo, Nagasaki, Japan, but since it was just Sasebo, our geocoders somehow figured out that there is a Sasebo Japanese Garden in Albequerque, and thought thats what the real location was. Looks like our geocoders are a little to smart for their own good!

    Thanks for bringing it up, Im sure there are a bunch of little discrepancies like this in other places well catch as TwitterWhere moves forward.

  12. 12 mattking
    Oct 28th, 2007 at 8:57 pm

    @adin: Also, fixed Chi-town

  13. 13 Brian Humphrey
    Dec 11th, 2007 at 3:43 pm


    Thanks for sharing the story behind a remarkable tool that were using to improve life safety in the City of Los Angeles.

    Respectfully Yours in Safety and Service,

    Public Service Officer
    Los Angeles Fire Department

  14. 14 Brandon Jan 11th, 2008 at 12:00 pm

    Hey Matt-

    Really cool tool but I am having trouble getting on the feed; maybe a bug?

    Feed that I never seem to show up on:

    My twittervision URL:

    As you can see twittervision seems to recognize me.



  15. 15 Mark
    Feb 9th, 2008 at 10:37 pm

    Matt, I havent received my twitterwhere feeds for the last week or so. The site page itself seems to be down. Did something get changed recently? I love the service and hope you are still maintaining it. Thanks!

  16. 16 gregflynn
    Apr 7th, 2008 at 2:09 pm

    Thanks for this tool. Have checked web version. FYI, etting an error message unzipping AIR version zip file. Screen shot of dialog box

  17. 17 Mark
    Apr 9th, 2008 at 9:53 pm


    Would it be possible (in your spare time) to filter out your own (ie: my) posts when looking for people within x miles of my zip?

    Also – could you add more distance to the drop down? Some of us (ok, ok, ME) live in rural places where 20 miles is a trip to the nearest town (if youre lucky).

    50, 100, 150, 200, 250 miles might work:)



  1. 1 Twitter + Location Based Feeds = TwitterWhere
    Pingback on Oct 25th, 2007 at 11:20 pm
  2. 2 Twitter + Location Based Feeds = TwitterWhere | – feed all tech!
    Pingback on Oct 26th, 2007 at 1:36 am
  3. 3 Twitter + Location Based Feeds = TwitterWhere at Geekstr
    Pingback on Oct 26th, 2007 at 3:31 am
  4. 4 » Blog Archive » Twitter + Location Based Feeds = TwitterWhere
    Pingback on Oct 27th, 2007 at 2:43 am
  5. 5 Main Blog Iphone » Blog Archive » Twitter + Location Based Feeds = TwitterWhere
    Pingback on Oct 27th, 2007 at 5:49 am
  6. 6 links for 2008-01-05 –
    Pingback on Jan 5th, 2008 at 1:24 am
  7. 7 Library clips :: Roundup :, TwitterWhere, vcasmo, kwout, ControlC :: January :: 2008
    Pingback on Jan 30th, 2008 at 7:14 pm

Leave a Reply

Your email address will not be published. Required fields are marked *