Skip to content
This repository
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 180 lines (174 sloc) 10.183 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
"""
Configuration describing the shapefiles to be loaded.
"""
from datetime import date

class simple_namer():
    """
Name features with a joined combination of attributes, optionally passing the result through a normalizing function.
"""
    def __init__(self, attribute_names, seperator=' ', normalizer=None):
        self.attribute_names = attribute_names
        self.seperator = seperator
        self.normalizer = normalizer

    def __call__(self, feature):
        attribute_values = map(str, map(feature.get, self.attribute_names))
        name = self.seperator.join(attribute_values).strip()
    
        if self.normalizer:
            normed = self.normalizer(name)
            if not normed:
                raise ValueError('Failed to normalize \"%s\".' % name)
            else:
                name = normed

        return name

SHAPEFILES = {
    # This key should be the plural name of the boundaries in this set
    'States': {
        # Path to a shapefile, relative to /data
        'file': 'STATE/',
        # Generic singular name for an boundary of from this set
        'singular': 'State',
        # Should the singular name come first when creating canonical identifiers for this set?
        # (e.g. True in this case would result in "Neighborhood South Austin" rather than "South Austin Neighborhood")
        'kind_first': False,
        # Function which each feature wall be passed to in order to extract its "external_id" property
        # The utils module contains several generic functions for doing this
        'ider': simple_namer(['GEOID10']),
        # Function which each feature will be passed to in order to extract its "name" property
        'namer': simple_namer(['NAME10']),
        # Authority that is responsible for the accuracy of this data
        'authority': 'U.S. Census Bureau, Geography Division',
        # Geographic extents which the boundary set encompasses
        'domain': 'United States',
        # Last time the source was checked for new data
        'last_updated': date(2011, 05, 21),
        # A url to the source of the data
        'href': 'http://www.census.gov/cgi-bin/geo/shapefiles2010/main',
        # Notes identifying any pecularities about the data, such as columns that were deleted or files which were merged
        'notes': '',
        # Encoding of the text fields in the shapefile, i.e. 'utf-8'. If this is left empty 'ascii' is assumed
        'encoding': 'latin-1'
        # SRID of the geometry data in the shapefile if it can not be inferred from an accompanying .prj file
        # This is normally not necessary and can be left undefined or set to an empty string to maintain the default behavior
        #'srid': ''
    },
    # This key should be the plural name of the boundaries in this set
    'Counties': {
        # Path to a shapefile, relative to /data
        'file': 'COUNTY/',
        # Generic singular name for an boundary of from this set
        'singular': 'County',
        # Should the singular name come first when creating canonical identifiers for this set?
        # (e.g. True in this case would result in "Neighborhood South Austin" rather than "South Austin Neighborhood")
        'kind_first': False,
        # Function which each feature wall be passed to in order to extract its "external_id" property
        # The utils module contains several generic functions for doing this
        'ider': simple_namer(['GEOID10']),
        # Function which each feature will be passed to in order to extract its "name" property
        'namer': simple_namer(['NAME10']),
        # Authority that is responsible for the accuracy of this data
        'authority': 'U.S. Census Bureau, Geography Division',
        # Geographic extents which the boundary set encompasses
        'domain': 'United States',
        # Last time the source was checked for new data
        'last_updated': date(2011, 05, 21),
        # A url to the source of the data
        'href': 'http://www.census.gov/cgi-bin/geo/shapefiles2010/main',
        # Notes identifying any pecularities about the data, such as columns that were deleted or files which were merged
        'notes': '',
        # Encoding of the text fields in the shapefile, i.e. 'utf-8'. If this is left empty 'ascii' is assumed
        'encoding': 'latin-1'
        # SRID of the geometry data in the shapefile if it can not be inferred from an accompanying .prj file
        # This is normally not necessary and can be left undefined or set to an empty string to maintain the default behavior
        #'srid': ''
    },
    # This key should be the plural name of the boundaries in this set
    'Places': {
        # Path to a shapefile, relative to /data
        'file': 'PLACE/',
        # Generic singular name for an boundary of from this set
        'singular': 'Place',
        # Should the singular name come first when creating canonical identifiers for this set?
        # (e.g. True in this case would result in "Neighborhood South Austin" rather than "South Austin Neighborhood")
        'kind_first': False,
        # Function which each feature wall be passed to in order to extract its "external_id" property
        # The utils module contains several generic functions for doing this
        'ider': simple_namer(['GEOID10']),
        # Function which each feature will be passed to in order to extract its "name" property
        'namer': simple_namer(['NAME10']),
        # Authority that is responsible for the accuracy of this data
        'authority': 'U.S. Census Bureau, Geography Division',
        # Geographic extents which the boundary set encompasses
        'domain': 'United States',
        # Last time the source was checked for new data
        'last_updated': date(2011, 06, 23),
        # A url to the source of the data
        'href': 'http://www.census.gov/cgi-bin/geo/shapefiles2010/main',
        # Notes identifying any pecularities about the data, such as columns that were deleted or files which were merged
        'notes': '',
        # Encoding of the text fields in the shapefile, i.e. 'utf-8'. If this is left empty 'ascii' is assumed
        'encoding': 'latin-1'
        # SRID of the geometry data in the shapefile if it can not be inferred from an accompanying .prj file
        # This is normally not necessary and can be left undefined or set to an empty string to maintain the default behavior
        #'srid': ''
    },
    # This key should be the plural name of the boundaries in this set
    'Tracts': {
        # Path to a shapefile, relative to /data
        'file': 'TRACT/',
        # Generic singular name for an boundary of from this set
        'singular': 'Tract',
        # Should the singular name come first when creating canonical identifiers for this set?
        # (e.g. True in this case would result in "Neighborhood South Austin" rather than "South Austin Neighborhood")
        'kind_first': False,
        # Function which each feature wall be passed to in order to extract its "external_id" property
        # The utils module contains several generic functions for doing this
        'ider': simple_namer(['GEOID10']),
        # Function which each feature will be passed to in order to extract its "name" property
        'namer': simple_namer(['NAME10']),
        # Authority that is responsible for the accuracy of this data
        'authority': 'U.S. Census Bureau, Geography Division',
        # Geographic extents which the boundary set encompasses
        'domain': 'United States',
        # Last time the source was checked for new data
        'last_updated': date(2011, 06, 23),
        # A url to the source of the data
        'href': 'http://www.census.gov/cgi-bin/geo/shapefiles2010/main',
        # Notes identifying any pecularities about the data, such as columns that were deleted or files which were merged
        'notes': '',
        # Encoding of the text fields in the shapefile, i.e. 'utf-8'. If this is left empty 'ascii' is assumed
        'encoding': 'latin-1'
        # SRID of the geometry data in the shapefile if it can not be inferred from an accompanying .prj file
        # This is normally not necessary and can be left undefined or set to an empty string to maintain the default behavior
        #'srid': ''
    },
    # This key should be the plural name of the boundaries in this set
    'County Subdivisions': {
        # Path to a shapefile, relative to /data
        'file': 'COUSUB/',
        # Generic singular name for an boundary of from this set
        'singular': 'County Subdivision',
        # Should the singular name come first when creating canonical identifiers for this set?
        # (e.g. True in this case would result in "Neighborhood South Austin" rather than "South Austin Neighborhood")
        'kind_first': False,
        # Function which each feature wall be passed to in order to extract its "external_id" property
        # The utils module contains several generic functions for doing this
        'ider': simple_namer(['GEOID10']),
        # Function which each feature will be passed to in order to extract its "name" property
        'namer': simple_namer(['NAME10']),
        # Authority that is responsible for the accuracy of this data
        'authority': 'U.S. Census Bureau, Geography Division',
        # Geographic extents which the boundary set encompasses
        'domain': 'United States',
        # Last time the source was checked for new data
        'last_updated': date(2011, 06, 23),
        # A url to the source of the data
        'href': 'http://www.census.gov/cgi-bin/geo/shapefiles2010/main',
        # Notes identifying any pecularities about the data, such as columns that were deleted or files which were merged
        'notes': '',
        # Encoding of the text fields in the shapefile, i.e. 'utf-8'. If this is left empty 'ascii' is assumed
        'encoding': 'latin-1'
        # SRID of the geometry data in the shapefile if it can not be inferred from an accompanying .prj file
        # This is normally not necessary and can be left undefined or set to an empty string to maintain the default behavior
        #'srid': ''
    },
}
Something went wrong with that request. Please try again.