예제 #1
0
    print "Bounding Box:", bounding_box
    print "Set ID:", set_id
    print "Time:", age_limit
    kwargs = {
        "num_segments": 4,
        "in_data_set_id": "global",
        "out_data_set_id": set_id,
        "min_timestamp": age_limit,
        "complex_filters": [police_beat],
        "min_lat": bounding_box["min_lat"],
        "max_lat": bounding_box["max_lat"],
        "min_lon": bounding_box["min_lon"],
        "max_lon": bounding_box["max_lon"]  # ,
        #        'keywords' : keywords
    }
    print "Filtering data..."
    worker.filter_data_parallel(**kwargs)
    print "Done filtering data..."

    print "Generating GeoJSON display..."
    if geojson is None:
        geojson = transformer.plot_points(set_id)
    else:
        geojson = transformer.plot_points(set_id, geojson)
    geojson = transformer.plot_polygon(police_beat, geojson)

print "Writing out GeoJSON display..."
outfile = open("all_beats_mayday_tweets.geojson", "w")
outfile.write(geojson)
outfile.close()
kwargs = {
    'num_segments' : 4,
    'in_data_set_id' : 'global',
    'out_data_set_id' : set_id,
    'min_timestamp' : age_limit,
    'complex_filters' : [police_beats],
    'min_lat' : bounding_box['min_lat'],
    'max_lat' : bounding_box['max_lat'],
    'min_lon' : bounding_box['min_lon'],
    'max_lon' : bounding_box['max_lon']
}
print "Filtering data..."
worker.filter_data_parallel(**kwargs)
print "Done filtering data..."

#print "Determine the trending topics..."
#topics = worker.calculate_trending_topics_parallel(data_set_id=set_id, num_segments=4)

#for topic in topics:
#    print topic[0], "=", topic[1]

# Generate the GeoJSON display
print "Generating GeoJSON display..."
geojson = transformer.plot_points(set_id)
geojson = transformer.plot_polygon(police_beats, geojson) #, properties={'topics' : str(topics)})

print "Writing out GeoJSON display..."
outfile = open('single_beat_last_hour_tweets.geojson', 'w')
outfile.write(geojson)
outfile.close()
예제 #3
0
    elif (avg_polarity < 0):
        polar_char = int(-avg_polarity * 16)
        if polar_char <= 9:
            polar_char = str(polar_char)
        else:
            polar_char = chr(64+polar_char-9)
 
        fill_color = polar_char + polar_char + '0000'

    fill_opacity = 1
    if avg_polarity == 0:
        fill_opacity = 0

    print "Fill Color:", fill_color
    print "Generating GeoJSON display..."
    if geojson is not None:
        geojson = transformer.plot_points(str(district_ids[iter]), geojson)
    else: 
        geojson = transformer.plot_points(str(district_ids[iter]))
    geojson = transformer.plot_polygon(districts[iter], geojson, properties={
        'num_points' : num_points,
        'polarity' : avg_polarity,
        'fill' : fill_color,
        'fill-opacity' : fill_opacity
    })

print "Writing out GeoJSON display..."
outfile = open('districts_sentiment.geojson', 'w')
outfile.write(geojson)
outfile.close()
예제 #4
0
kwargs = {
    'num_segments' : 4,
    'in_data_set_id' : 'global',
    'out_data_set_id' : set_id,
    'min_timestamp' : age_limit,
    'complex_filters' : [franklin_county],
    'min_lat' : bounding_box['min_lat'],
    'max_lat' : bounding_box['max_lat'],
    'min_lon' : bounding_box['min_lon'],
    'max_lon' : bounding_box['max_lon']
}
print "Filtering data..."
worker.filter_data_parallel(**kwargs)
print "Done filtering data..."

print "Determine the trending topics..."
topics = worker.calculate_trending_topics_parallel(data_set_id=set_id, num_segments=4)

for topic in topics:
    print topic[0], "=", topic[1]

# Generate the GeoJSON display
print "Generating GeoJSON display..."
#geojson = transformer.plot_points(set_id)
geojson = transformer.plot_polygon(franklin_county, properties={'topics' : str(topics)})

print "Writing out GeoJSON display..."
outfile = open('franklin_county_this_hour.geojson', 'w')
outfile.write(geojson)
outfile.close()
예제 #5
0
bounding_box = franklin_county.get_bounding_box()
keywords = ['robbery', 'gun', 'steal', 'crime', 'shooter', 'robber', 'weapon', 'shoota']
print "Bounding Box:", bounding_box
print "Set ID:", set_id
print "Time:", age_limit
kwargs = {
    'num_segments' : 4,
    'in_data_set_id' : 'global',
    'out_data_set_id' : set_id,
    'min_timestamp' : age_limit,
    'complex_filters' : [franklin_county],
    'min_lat' : bounding_box['min_lat'],
    'max_lat' : bounding_box['max_lat'],
    'min_lon' : bounding_box['min_lon'],
    'max_lon' : bounding_box['max_lon']
#    'keywords' : keywords
}
print "Filtering data..."
worker.filter_data_parallel(**kwargs)
print "Done filtering data..."

# Generate the GeoJSON display
print "Generating GeoJSON display..."
geojson = transformer.plot_points(set_id)
geojson = transformer.plot_polygon(franklin_county, geojson)

print "Writing out GeoJSON display..."
outfile = open('franklin_county_this_hour.geojson', 'w')
outfile.write(geojson)
outfile.close()