Search code examples
twittergeolocationgnip

Twitter Profile Geo Enrichment for the UK


In the premium operators section of the Twitter API documentation, they have operators that can be used to filter based on the Profile Geo Enrichment data. In particular, you can filter by profile_region. An example being profile_region:"Zurich" which worked as expected to return tweets from Users that are based in Zurich. However, profile_region:"London" and profile_region:"Greater London" both lead to the request returning 0 results. The limitations on the number of these requests that can be made (per month) discouraged me from keep trying things until it worked.

I have searched the Twitter documentation, the old documentation for the API on gnip.com and also the GeoNames.org to try and find what twitters definition of a UK region or simply an example of a place in the UK, however, have been unsuccessful.

I have also used the user/search API to gather user_objects of users located in London to find the derived field (which should contain the Profile Geo Enriched data) but found that this was missing.


Solution

  • There are a number of "levels" to profile geo:

    • profile_region
    • profile_subregion
    • profile_locality

    If you use profile_locality:London you'll see different results (or profile_subregion:"Greater London"). The London object looks like this:

    {
      "locations": [
        {
          "country": "United Kingdom",
          "country_code": "GB",
          "locality": "London",
          "region": "England",
          "sub_region": "Greater London",
          "full_name": "London, England, United Kingdom",
          "geo": {
            "coordinates": [
              -0.12574,
              51.50853
            ],
            "type": "point"
          }
        }
      ]
    }