Examples: Searching Twitter by location and with specific keywords

This page is part of the Twitter location search resource on Thoughtfaucet which contains tutorials for Tweetdeck and Hootsuite, examples, caveats and how to find latitude and longitude in order to make a geocode. Church Street, Burlington, Vermont

Here are a selection of Twitter searches by location. Each one has a geocode and map so you know how far it reaches.

If you don’t find the search code you need in this reference, leave a comment and let me know what you’re after. I’ll update this reference.

Twitter search can filter by the location of a Tweet if the user has location services turned on. If the Twitter user doesn’t have location turned on, Twitter can filter tweets based on the location in a Twitter user’s profile. If that is left blank, then you won’t be able to find that Tweet using a standard location search.

Additional background on this concept is at the beginning of the online version of my Listening Strategy presentation.

Using geocodes to filter tweets based on location is what locative media geeks refer to as setting up a geofence. Here are some example geofences and their twitter search strings.

Tweets from Capitol, Jan 6

Following a speech by Donald Trump telling people to go to the Capitol and disrupt the electoral vote certification, many people did. Some of them were using Twitter.
Lat/Long coordinates of the US Capitol for finding Tweets from 1/6/2021
After you find the lat/long coordinates, you can enter them in Twitter
Entering the search string below let’s you use twitter location search to see their tweets:
The above string will give you Tweets in a 0.02km radius around the Capitol. You can expand or shrink the geofence however you like however you like. But if you want to search Twitter for a specific date range, for example, 1/6/2021, you’ll need to add that as well:
since:2021-01-05 until:2021-01-07

Example: Tweets about Hurricane Sandy in Vermont

One of the specific ways that geocoded Twitter searches get used is during emergencies and weather events. The challenge with using Twitter to monitor these kinds of things is that people use a variety of relevant terms–some official, some folksonomic, some just random relevant words. A search radius that focuses on Vermont, useful for our Hurricane Sandy Twitter filter. Here is an example of a geocoded search string for following Vermont tweets related to the Sandy storm of late October 2012: -RT -election power OR #vtsandy OR #vtresponse OR #frankenstorm OR sandy OR flood geocode:43.913723261972855,-72.54272478125,150km This search eliminates retweets that include the “RT” customary signal and include a variety of word markers. I’ve eliminated the word “election” as well to keep the search focused on things which are immediately important in an emergency environment. You’ll notice from the image that, since Vermont isn’t a very round state that we’ll be pulling in Twitter posts from some of the areas around Vermont as well. Also note that in addition to hashtags this twitter location search filter also includes the words “power” and “flood” in case people are tweeting about those words but don’t know about hashtags etc.

Example: NYC Hurricane Sandy Twitter search

This is pretty much the same as the Vermont search above but is instead set to cover New York City. Radius for a Twitter search covering NYC during 2012's Hurricane Sandy
-RT -election power OR #sandy OR #frankenstorm 
OR sandy OR flood OR surge 

Example: Tweets with #BTV hashtag OR #BVT hashtag within 200km of Burlington, VT (Vermont, Montreal, Quebec, Upstate NY and some NH)

Sometimes you want to do an either or kind of search. For example, in Burlington Vermont there are two hashtags which get used: #BTV and #BVT.

Some people use both, some people use only one. If you want to merge those streams and limit by geography, use this search string. Note, that this technique will work with any of the other search strings as well.

#btv OR #bvt geocode:44.467186,-73.214804,200km

Example: Tweets with #BTV hashtag within 200km of Burlington, VT (Vermont, Montreal, Quebec, Upstate NY and some NH)

Contains the #BTV hashtag and is located within 200KM of Burlington VT:
#btv geocode:44.467186,-73.214804,200km
If you don’t care if a tweet has #BTV in it or not, use this code instead:

Example: Tweets with #BTV hashtag within 2500km of Burlington Vermont

Here is the code to generate this location-based search result in Twitter: Has the #BTV hashtag and is within 2500km of Burlington, VT
#btv geocode:44.467186,-73.214804,2500km
If you don’t care whether a Tweet has the #BTV hashtag or not, and just want to use the geofence use this query instead:

Example: Tweets with #BTV hashtag centered on the lower 48 states USA

Contains hashtag #BTV, centered to reach the lower 48 states of the USA with a radius of 2500km (maximum):
#btv geocode:39.8,-95.583068847656,2500km
If you don’t care whether a Tweet has the #BTV hashtag or not, use this code:

Example: Tweets with “malaria” within 500k of the Whalley Arms public house, UK.

Contains the word “malaria” and is within 500km of the Whalley Arms public house in Whalley UK.
malaria geocode:53.81982,-2.406348,500km

Example: Tweets within 100 meters of New York’s Zuccotti Park

Combining some of the techniques you’ll see in the other examples, you can search for just Tweets that originate within 100meters of Zuccotti Park and also contain the hashtag #OWS, which is often used on Tweets specific to the “Occupy Wall Street” movement.
#ows geocode:40.709,-74.011,.1km
Want a Twitter location search you don’t see in this reference? Let me know in the comments and I’ll see if I can cook it up for you

Join the Conversation


    1. Unfortunately you cannot set a polygon or draw a border to find tweets by geography. It only works with a center and radius. If you set up multiple searches you can overlap them in other software to create other kinds of shapes, but that’s just adding up circles as well.

      It’s tricky for certain and less than ideal. But there often ways to get close to what you need if you get creative with how you assemble the circles.

  1. Can we specify time limit with geocode? eg., to get tweets from particular time frame from particular geolocation. What are the solutions for this problem?

    1. It’s working. Probably an issue with formatting on your side. It’s super picky about spaces etc.

    1. Still works in the Twitter interface. It’s been awhile so I should probably update this page for Tweetdeck.

    1. Yes, use decimals. But it gets less useful because the location data is truly coming from the network service of the user. So I sort of consider it a town-by-town or part-of-town thing.

  2. Hey, so I am trying to pull tweets with a certain emoji in the United States. Is this possible? Also, what are you using where you show code? Currently I am using python.

    1. It does! You just need to enter the code for the emoji (or paste it into the search bar).

  3. Hello there. In your first two examples you had “-election power” as your exclusion criteria. I am new to this so I am wondering, should your string have been “-election -power” or is the search engine smart enough to know you wanted to exclude “election power” (two words)?

    1. If you want to eliminate more than one word you will need the – in front of each individual word. In the example, I _wanted_ tweets that included power because the search was about finding people who were without power in an emergency. I wanted to exclude tweets with election in them because Vermonters love to talk about politics on twitter and there was just too much noise at that time to find those who were without power.

  4. You should date your articles. I have no idea how old this one is, but a cursory glance suggests that this is no longer relevant to the current platform.

    1. You are mistaken, Brian. These searches all work just fine in the Twitter search box. Just tested them. Thanks for reading though!

  5. Hello,
    Is it possible to search for a tweet based on geolocalisation? I mean if my understanding is correct using geo means searching for tweets in this area, but is it possible to search for a localisation and not for a tweet send in this area

    1. Hello Halima,

      It is not possible to search for tweets about a specific radius–geolocalisation. Unfortunately, for that kind of thing you may be left with just searching for tweets containing the place-name (and any variations you find). The end result would certainly be quite noisy, but you may be able to refine it once you gain experience with the resulting data set.

      Thank you for this great question (and I wish the answer were different)!

Leave a comment

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