Skip to main content

Export Twitter searches to GeoJSON

Project description

Export geotagged tweets to GeoJSON.

Install

Open your terminal and run:

pip install twittergeo

(Don’t have Pip?)

Use

To use the tool, you’ll need a application registered with Twitter. Instructions from Twitter: https://apps.twitter.com.

When your application is set, you’ll get two keys, which need to be added to a config file.

Setting up a config file

Pasting in your consumer key and secret every time is boring. Save a config file like so:

apps:
    twittergeo:
        consumer_key: ...
        consumer_secret: ...

Call the file bots.yaml and save it in your home directory, and twittergeo will find it automatically. Or use a custom file:

$ twittergeo --search "some words" --config configfile.yaml -o some_words.geojson

Smaller files

Use the --lite option to get smaller files. The only properties saved will be the tweet’s text and ID, and the user’s screen_name and userid.

$ twittergeo --search "some words" --lite > some_words.geojson

Get more tweets

By default, Twitter returns only 15 tweets, which is pretty weak. Use the --count parameter to request more. Note that Twittergeo will return count tweets, but ignore non-geotagged tweets, so your files will likely be much shorter. The Twitter API doesn’t have a way request only geotagged tweets.

$ twittergeo --search "some words" --count 100 > some_words.geojson

Geocode parameter

When using the search option, you can request tweets close to a particular point. The format to use is latitude,longitude,radius, where radius is either in miles (mi) or kilometers (km).

$ twittergeo --search "some words" --geocode 37.781157,-122.398720,1mi -o some_words_a.geojson
$ twittergeo --search "some words" --geocode 37.781157,-74.2644,10km -o some_words_b.geojson

Options

usage: twittergeo [-h] [-c path] [--app APP] [-u screen_name | -f search]
                  [--lite] [--count COUNT] [--geocode LAT,LON,RADIUS]
                  [--since ID] [--max ID] [-o OUTPUT]

Pull Twitter searches into GeoJSON

optional arguments:
  -h, --help            show this help message and exit
  -c path, --config path
                        jsom or yaml config file
  --app APP             Twitter app to read in config (default: twittergeo)
  -u screen_name, --user screen_name
                        User timeline to search
  -f search, --search search
                        Search string
  --lite                Output minimal information about tweets
  --count COUNT         Maximum number of tweets to return (default: 100)
  --geocode LAT,LON,RADIUS
                        optional geocode parameter when searching
  --since ID            Fetch tweets since this ID
  --max ID              Fetch tweets before this ID
  -o OUTPUT, --output OUTPUT
                        output file (default: stdout)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

twittergeo-0.2.0.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

twittergeo-0.2.0-py2.py3-none-any.whl (7.6 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file twittergeo-0.2.0.tar.gz.

File metadata

  • Download URL: twittergeo-0.2.0.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for twittergeo-0.2.0.tar.gz
Algorithm Hash digest
SHA256 db41ae577e37c258244c5a82a83a3d05fd068fca97b9b01c5933318cf75a05f1
MD5 d90df75e8e63296dfffe973d94eb265b
BLAKE2b-256 65dfc00bc751aa6b8ca40caca2612d7d21eeb8007e632447e0b7736a431d40e2

See more details on using hashes here.

File details

Details for the file twittergeo-0.2.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for twittergeo-0.2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 92b91fbbb750b351d82741716cd60552918eec7fddc36b94c109d43b485907d1
MD5 dbe5fc2eed8a0cd6442097f15a4f5ce8
BLAKE2b-256 2443d0037e8114347fee1eff8a41eac39c881094a5ec68c1c3714a63e8a2060b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page