BryceSoker
BryceSoker

Reputation: 644

Tweepy filtering multiple location

So I am using the Tweepy to try and get streams from several squared locations to work on a GIS project. I tried using a list as a filter but it seems to not be possible:

l = StdOutListener()
stream = Stream(auth, l)
stream.filter(locations={[-4.62,41.97,10.49,51.1],[-87.6,24.73,-75.41,32.12]}) #Doesn't work

Does anyone knows if there is any alternative, since multiple threads would also not work since they check IPs so multiple Auths would not work either.

Upvotes: 0

Views: 700

Answers (1)

Shwetanshu Singh
Shwetanshu Singh

Reputation: 36

According to the locations section of the parameter listing in the Developer documentation for the Streaming end-point:

-122.75,36.8,-121.75,37.8,-74,40,-73,41

translates to

San Francisco OR New York City

so, accordingly, your code should be formatted to

... stream.filter(locations=[-4.62,41.97,10.49,51.1,-87.6,24.73,-75.41,32.12])

as a single list of all locations following the South-West and North-East grouping; thereby, as a sanity check please ensure that your locations list be a multiple of four (allowing for a latitude and longitude each for SW and NE coordinates for each bounding box) and also that NE coordinates > SW coordinates.

Please be sure to keep in mind that the stream API end-point permits the filtering of only

...25 0.1-360 degree location boxes.

Upvotes: 2

Related Questions