Example #1
0
def make_2013_dots():
    print 'making 2013 ACS block group dots'
    args = [
        'PG:dbname=nola_demographics host=localhost', 'block_groups_2013',
        'ESRI Shapefile', 'output/dots-2013', 'dots-2013', get_2013_data,
        DOT_DIVISOR
    ]
    dots = DotDensityPlotter(*args)
    dots.plot()
Example #2
0
def make_2013_dots():
    print 'making 2013 ACS block group dots'
    args = [
        'PG:dbname=nola_demographics host=localhost',
        'block_groups_2013',
        'ESRI Shapefile',
        'output/dots-2013',
        'dots-2013',
        get_2013_data,
        DOT_DIVISOR
    ]
    dots = DotDensityPlotter(*args)
    dots.plot()
Example #3
0
#!/usr/bin/env python

from englewood import DotDensityPlotter 

def get_data(feature):
    return {
        'under18': feature.GetFieldAsInteger(feature.GetFieldIndex('under18')),
        'under25': feature.GetFieldAsInteger(feature.GetFieldIndex('under25')),
        'under40': feature.GetFieldAsInteger(feature.GetFieldIndex('under40')),
        'under65': feature.GetFieldAsInteger(feature.GetFieldIndex('under65')),
        'gte65': feature.GetFieldAsInteger(feature.GetFieldIndex('gte65')),
    }

dots = DotDensityPlotter('PG:dbname=tylercensus host=localhost', 'age_shapes', 'PostgreSQL', 'PG:dbname=tylercensus host=localhost', 'age_dots', get_data, 1)
dots.plot()

Example #4
0
def get_data(feature):
    # The third column of the shapefile is the ward number
    ward_id = feature.GetField(2)

    # Get the correct ward data
    try:
        ward = ward_data[ward_id]
        print 'Processing ward "%s"' % ward_id
    except KeyError:
        print 'No data for ward "%s"' % ward_id
        return None

    return {
        'asian': int(ward['nhasian10']),
        'black': int(ward['nhblack10']),
        'hispanic': int(ward['hisp10']),
        'white': int(ward['nhwhite10']),
    }


# Ensure the output path exists
if not os.path.exists(OUTPUT_PATH):
    os.mkdir(OUTPUT_PATH)

# Create a map with one dot for every 25 people of each group
# Each dot will have an attribute 'GROUP' that will be one of
# 'asian', 'black', 'hispanic', or 'white'.
dots = DotDensityPlotter(INPUT_PATH, INPUT_LAYER, 'ESRI Shapefile',
                         OUTPUT_PATH, OUTPUT_LAYER, get_data, 25)
dots.plot()