nplnt
#1
Hi everyone,
I tried to use the full-archive search endpoint to get geotagged tweets by python. Since I need the coordinates of the locations, I added geo.coordinates to tweet.fields in the request’s query parameter according to the documentation. However, I got an error message "The tweet.fields query parameter value [geo.coordinates] is not one of [attachments,author_id,context_annotations,conversation_id,created_at,entities,geo,id,in_reply_to_user_id,lang,non_public_metrics,organic_metrics,possibly_sensitive,promoted_metrics,public_metrics,referenced_tweets,reply_settings,source,text,withheld]
If I only added geo to tweet.fields, the response would only include place_id. It is not helpful because the very strict rate limit of GET geo/id/:place_id. Is there any solution could give me coordinates of the geotagged tweets without looking up place_id? Thanks in advance.
you need: expansions and place.fields and tweet.fields:
expansions=geo.place_id&tweet.fileds=geo&place.fields=contained_within,country,country_code,full_name,geo,id,name,place_type
in your request
Then, tweets will have geo place ids, and inside includes, not in data you will find places with all the expanded geo objects.
I recommend using twarc for full archive searches: GitHub - DocNow/twarc: A command line tool (and Python library) for archiving Twitter JSON
nplnt
#3
Thank you for your reply. I’m wondering besides bbox, is it possible to get also centroid?
No, you might have to get that yourself somehow - this is all that twitter API provides: Place objects | Docs | Twitter Developer Platform
nplnt
#5
So it includes only bounding boxes instead of exactly polygons?
Yeah - the geo part of the Place object is GeoJSON format but unfortunately Place objects | Docs | Twitter Developer Platform is all the fields that are available - any extra data like exact polygons you’ll have to somehow get elsewhere