Created
January 3, 2014 18:49
-
-
Save ptwobrussell/8243923 to your computer and use it in GitHub Desktop.
A little script for converting tweets with geocoords to geojson format. (The script assumes that you've flattened the tweets down to a CSV format with the field format described in the tuple of the "for" loop, which is easy enough to do.)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import geojson | |
import sys | |
lines = [line.strip().split("\t") for line in open(sys.argv[1]).readlines()] | |
features = [] | |
for (x, y, _id, text, screen_name, utc) in lines: | |
props = dict(text=text, screen_name=screen_name, utc=utc) | |
features.append( geojson.Feature(id=_id, geometry=geojson.Point(coordinates=(x,y)), properties=props) ) | |
feature_collection = geojson.FeatureCollection(features) | |
print geojson.dumps(feature_collection, indent=1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment