Skip to main content

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

You’ll need a bots.yaml (or .json) file with you keys, because copying and pasting them is boring, and environment variabled don’t work if you have several applications. Save a config file like so:

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

Call the file bots.yaml and save it in your home directory. 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 that may include 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: 500)
  --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)

Metadata

Release files for twittergeo 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for twittergeo 0.2.1
File Size Uploaded
twittergeo-0.2.1.tar.gz 6.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for twittergeo 0.2.1
File Interpreter ABI Platform
twittergeo-0.2.1-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 14.4 kB

Release files / twittergeo-0.2.1.tar.gz

Download URL twittergeo-0.2.1.tar.gz
Size 6.7 kB
Tags Source
SHA-256 checksum
How to use checksums
815d16ead035c0f013424be96bff87ba16d1f6403acecde90a17fa68fff0204a
BLAKE2b-256 checksum
How to use checksums
af6256411208a73e67f2b31db8d0ee0a7f3c24ae9cd561b57bfd5b0f664a0b2d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / twittergeo-0.2.1-py2.py3-none-any.whl

Download URL twittergeo-0.2.1-py2.py3-none-any.whl
Size 7.7 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
354a1946e8a91ade372da3b6ca6553e5cb1898ad6e06007d2cf15565e48ac74e
BLAKE2b-256 checksum
How to use checksums
2bc2ee06b1c317bf73badf34e97fdffd00f4e4ccafe21010d72f185a6cfa678e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page