chrishillonline
chrishillonline

Reputation: 25

How to obtain geographic location (data) via a Twitter Streams api query?

I am using the twitter streaming api and have created a stream about #javascript but I want to pitch my tweets on a map.

Every response I get in any of the geo or locations field is null. So I need some form of elevated privilege or is the tweets location something I'm not allowed to query?

Upvotes: 1

Views: 970

Answers (1)

Jonas
Jonas

Reputation: 4048

There is no extra privilege for this. You have a few options, all of which yield a very low percentage of geo-located tweets.

The geo field used to be filled with coordinates for about 1% of all tweets. Twitter this year began returning even fewer tweets with geo coordinates.

These days, you will get a small percentage of tweets with place, which contains the coordinates for a bounding box. This may not be useful for you if you want to map a point, although you could calculate the center of the box and map that. Also, place is manually selected when tweeting, so it's meaning is questionable.

Your last option is the location field which users fill in about half the time. It's a fixed location that the user identifies with. Often it's some sarcastic comment. Still, location is usable if you send it to a geolocation service which will return its latitude and longitude. Like place, location has questionable significance.

Upvotes: 4

Related Questions