예제 #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()
예제 #2
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()