コード例 #1
0
    def setUp(self):
        self.definition = definition = Definition({
            'last_updated': date(2000, 1, 1),
            'encoding': 'utf-8',
            'name': 'Districts',
            'name_func': clean_attr('Name'),
            'id_func': attr('ID'),
            'slug_func': attr('Code'),
            'is_valid_func': lambda f: f.get('ID') == '1',
            'label_point_func': lambda f: Point(0, 1),
        })

        self.fields = {
            'Name': 'VALID',
            'ID': '1',
            'Code': '\tFoo—Bar–Baz \r Bzz\n',  # m-dash, n-dash
        }

        self.boundary_set = BoundarySet(
            last_updated=definition['last_updated'],
            name=definition['name'],
            singular=definition['singular'],
        )

        self.feature = Feature(FeatureProxy(self.fields), definition)

        self.other = Feature(FeatureProxy({
            'Name': 'INVALID',
            'ID': 100,
            'Code': 3,
        }), definition, SpatialReference(4269), self.boundary_set)
コード例 #2
0
def namer(f):
    import boundaries

    n = boundaries.attr("NAME")(f)
    if n == "Kellys Cove":
        return "Kelly's Cove"
    return n
コード例 #3
0
def namer(f):
    import boundaries
    if f.get('CO_MUNCP') == 43027:
        return {
            'Le Mont-Bellevue': 'Mont-Bellevue',
            'Rock Rorest--Saint-lie--Deauville': 'Rock Forest—Saint-Élie—Deauville',
        }.get(f.get('NM_ARON'), f.get('NM_ARON'))
    else:
        return boundaries.attr('NM_ARON')(f)
コード例 #4
0
    def setUp(self):
        self.definition = definition = Definition({
            'last_updated':
            date(2000, 1, 1),
            'encoding':
            'utf-8',
            'name':
            'Districts',
            'name_func':
            clean_attr('Name'),
            'id_func':
            attr('ID'),
            'slug_func':
            attr('Code'),
            'is_valid_func':
            lambda f: f.get('ID') == '1',
            'label_point_func':
            lambda f: Point(0, 1),
        })

        self.fields = {
            'Name': 'VALID',
            'ID': '1',
            'Code': '\tFoo—Bar–Baz \r Bzz\n',  # m-dash, n-dash
        }

        self.boundary_set = BoundarySet(
            last_updated=definition['last_updated'],
            name=definition['name'],
            singular=definition['singular'],
        )

        self.feature = Feature(FeatureProxy(self.fields), definition)

        self.other = Feature(
            FeatureProxy({
                'Name': 'INVALID',
                'ID': 100,
                'Code': 3,
            }), definition, SpatialReference(4269), self.boundary_set)
コード例 #5
0
def ider(f):
    """
    http://www.ville.dorval.qc.ca/en/downloads/pdf/Map_Electoral_Districts.pdf
    """
    import boundaries
    return {
        'Désiré-Girouard': '1',
        'La Présentation': '2',
        'Fénelon': '3',
        'Pine Beach': '4',
        'Strathmore': '5',
        'Surrey': '6',
    }[boundaries.attr('NOM_DISTRI')(f)]
コード例 #6
0
def ider(f):
    """
    http://www.ville.dorval.qc.ca/en/downloads/pdf/Map_Electoral_Districts.pdf
    """
    import boundaries
    return {
        u'Désiré-Girouard': '1',
        u'La Présentation': '2',
        u'Fénelon': '3',
        u'Pine Beach': '4',
        u'Strathmore': '5',
        u'Surrey': '6',
    }[boundaries.attr('NOM_DISTRI')(f)]
コード例 #7
0
ファイル: loading.py プロジェクト: todrobbins/sitegeist
def load_zcta_boundaries():

    # clear registry
    boundaries.registry = {}

    dl_path = _dl_path()
    today = datetime.date.today()

    for state in us.STATES:

        print state.name

        url = state.shapefile_urls('zcta')
        filename = url.split('/')[-1]
        (name, ext) = filename.rsplit('.', 1)

        extract_path = os.path.join(dl_path, name)
        if not os.path.exists(extract_path):

            os.mkdir(extract_path)

            zip_path = os.path.join(dl_path, filename)
            if not os.path.exists(zip_path):
                resp = requests.get(url)
                with open(zip_path, 'w') as outfile:
                    outfile.write(resp.content)

            with zipfile.ZipFile(zip_path, 'r') as archive:
                archive.extractall(extract_path)

            os.unlink(zip_path)

        boundaries.register(
            '%s-zcta' % state.name.lower().replace(' ', ''),
            singular='census-zcta',
            domain='US',
            file=extract_path,
            last_updated=today,
            name_func=name_func(state.name, 'ZCTA5CE10'),
            id_func=boundaries.attr('ZCTA5CE10'),
            slug_func=slug_func('ZCTA5CE10'),
            label_point_func=label_point_func,
            authority='United States Census Bureau',
            source_url='http://www.census.gov/cgi-bin/geo/shapefiles2010/main',
            data_url=url,
        )

    from django.core import management
    management.call_command('loadshapefiles')
コード例 #8
0
ファイル: loading.py プロジェクト: bartonlorimor/sitegeist
def load_zcta_boundaries():

    # clear registry
    boundaries.registry = {}

    dl_path = _dl_path()
    today = datetime.date.today()

    for state in us.STATES:

        print state.name

        url = state.shapefile_urls('zcta')
        filename = url.split('/')[-1]
        (name, ext) = filename.rsplit('.', 1)

        extract_path = os.path.join(dl_path, name)
        if not os.path.exists(extract_path):

            os.mkdir(extract_path)

            zip_path = os.path.join(dl_path, filename)
            if not os.path.exists(zip_path):
                resp = requests.get(url)
                with open(zip_path, 'w') as outfile:
                    outfile.write(resp.content)

            with zipfile.ZipFile(zip_path, 'r') as archive:
                archive.extractall(extract_path)

            os.unlink(zip_path)

        boundaries.register('%s-zcta' % state.name.lower().replace(' ', ''),
            singular='census-zcta',
            domain='US',
            file=extract_path,
            last_updated=today,
            name_func=name_func(state.name, 'ZCTA5CE10'),
            id_func=boundaries.attr('ZCTA5CE10'),
            slug_func=slug_func('ZCTA5CE10'),
            label_point_func=label_point_func,
            authority='United States Census Bureau',
            source_url='http://www.census.gov/cgi-bin/geo/shapefiles2010/main',
            data_url=url,
        )

    from django.core import management
    management.call_command('loadshapefiles')
コード例 #9
0
def namer(f):
    import boundaries
    n = boundaries.attr('ARROND')(f)
    return {
        u'Cote-des-Neiges--Notre-Dame-de-Grace': u'Côte-des-Neiges—Notre-Dame-de-Grâce',
        u"L'Ile-Bizard--Sainte-Genevieve": u"L'Île-Bizard—Sainte-Geneviève",
        u'Mercier-Hochelaga-Maisonneuve': u'Mercier—Hochelaga-Maisonneuve',
        u'Montreal-Nord': u'Montréal-Nord',
        u'Pierrefonds--Roxboro': u'Pierrefonds-Roxboro',
        u'Plateau-Mont-Royal': u'Le Plateau-Mont-Royal',
        u'Pointe-aux-Trembles-Rivieres-des-Prairies': u'Rivière-des-Prairies—Pointe-aux-Trembles',
        u'Rosemont--La-Petite-Patrie': u'Rosemont—La Petite-Patrie',
        u'St-Leonard': u'Saint-Léonard',
        u'Sud-Ouest': u'Le Sud-Ouest',
        u'Verdun--Ile-des-Soeurs': u'Verdun',
        u'Villeray-Saint-Michel-Parc-Extension': u'Villeray—Saint-Michel—Parc-Extension',
    }.get(n, n)
コード例 #10
0
from datetime import date

import boundaries

boundaries.register('British Columbia electoral districts',
    domain='British Columbia',
    last_updated=date(2011, 12, 12),
    name_func=boundaries.attr('edname'),
    id_func=boundaries.attr('edabbr'),
    authority='Elections BC',
    source_url='http://www.elections.bc.ca/index.php/voting/electoral-maps-profiles/geographic-information-system-spatial-data-files-2011/',
    data_url='http://www.elections.bc.ca/docs/map/redis11/GIS/ED_Province.exe',
    encoding='iso-8859-1',
)
コード例 #11
0
from datetime import date

import boundaries

boundaries.register('Oakville wards',
    domain='Oakville, ON',
    last_updated=date(2018, 6, 11),
    name_func=lambda f: 'Ward %s' % f.get('Ward'),
    id_func=boundaries.attr('Ward'),
    authority='Town of Oakville',
    source_url='https://portal-exploreoakville.opendata.arcgis.com/datasets/toak::2018-ward-boundaries',
    licence_url='https://www.oakville.ca/data/open_data_licence.html',
    data_url='https://opendata.arcgis.com/datasets/36137fb86deb4431b53450cf16370a3b_0.zip',
    encoding='iso-8859-1',
    extra={'division_id': 'ocd-division/country:ca/csd:3524001'},
)
コード例 #12
0
# coding: utf-8
from datetime import date

import boundaries

boundaries.register(
    'Quebec electoral districts (2011)',
    singular='Quebec electoral district',
    domain='Quebec',
    last_updated=date(2012, 2, 24),
    name_func=boundaries.clean_attr('NM_CEP'),
    id_func=boundaries.attr('CO_CEP'),
    authority='Directeur général des élections du Québec',
    source_url=
    'https://www.electionsquebec.qc.ca/francais/provincial/carte-electorale/geometrie-des-circonscriptions-provinciales-du-quebec.php',
    licence_url=
    'https://www.electionsquebec.qc.ca/francais/conditions-d-utilisation-de-notre-site-web.php',
    data_url=
    'https://www.electionsquebec.qc.ca/documents/zip/circonscriptions-electorales-2011-shapefile-v2.zip',
    encoding='windows-1252',
    extra={'division_id': 'ocd-division/country:ca/province:qc'},
)
コード例 #13
0
from datetime import date

import boundaries

boundaries.register('Empty',
  last_updated=date(2000, 1, 1),
  name_func=boundaries.attr('id'),
  file='../../fixtures/empty.zip',
)
コード例 #14
0
from datetime import date

import boundaries

boundaries.register('Pennsylvania Places',
    domain='Pennsylvania',
    last_updated=date(2012, 11, 29),
    name_func=boundaries.attr('NAME'),
    id_func=boundaries.attr('GEOID'),
    slug_func=boundaries.attr('GEOID'),
    authority='United States Census Bureau',
    source_url='http://www.census.gov/cgi-bin/geo/shapefiles2012/main',
    data_url='http://www2.census.gov/geo/tiger/TIGER2012/PLACE/tl_2012_42_place.zip',
)
コード例 #15
0
    '1313002': ['Saint-André', 'Saint-André'],
    '1313027': ['Edmundston', 'Edmunston'],
    '1314019': ['Kedgwick', 'Kedgwick'],
    '1314025': ['Belledune', 'Belledune'],
    '1315027': ['Bas-Caraquet', 'Bas-Caraquet'],
    '1315028': ['Caraquet', 'Caraquet'],
}

for geographic_code, (name, machine_name) in sets.items():
    boundaries.register(
        '%s wards' % name,
        file='%s.shp' % name,
        domain='%s, NB' % name,
        last_updated=date(2014, 3, 24),
        name_func=lambda f: 'Ward %s' % f.get('WARD_ID'),
        id_func=boundaries.attr('WARD_ID'),
        authority='Her Majesty the Queen in Right of New Brunswick',
        source_url=
        'http://geonb.snb.ca/ArcGIS/rest/services/ElectionsNB/GeoNB_ENB_MunicipalWards/MapServer/0',
        licence_url=
        'http://geonb.snb.ca/downloads/documents/geonb_license_e.pdf',
        encoding='iso-8859-1',
        metadata={'geographic_code': geographic_code},
        ogr2ogr='''-where "MUN_NAME='%s'"''' % machine_name,
        base_file='OGRGeoJSON.shp',
    )

boundaries.register(
    'Beresford wards',
    file='Beresford.shp',
    domain='Beresford, NB',
コード例 #16
0
from __future__ import unicode_literals

from datetime import date

import boundaries

boundaries.register(
    'Alberta electoral districts',
    domain='Alberta',
    last_updated=date(2012, 6, 4),
    name_func=boundaries.clean_attr('EDNAME'),
    id_func=boundaries.attr('EDNUMBER'),
    authority='Her Majesty the Queen in Right of Alberta',
    source_url='http://www.altalis.com/products/base/20k_base_features.html',
    licence_url='http://data.alberta.ca/licence',
    # The data_url contains multiple shapefiles, and the URL expires.
    # data_url='http://data.altalis.com/AltalisDataDownload/Download/525711F29A214C1AB5ED8F5578A983C3',
    encoding='iso-8859-1',
    extra={'division_id': 'ocd-division/country:ca/province:ab'},
)
コード例 #17
0
from datetime import date

import boundaries

boundaries.register(
    'Polygons',
    last_updated=date(2000, 1, 1),
    name_func=boundaries.attr('str'),
)
コード例 #18
0
from __future__ import unicode_literals

from datetime import date

import boundaries

# Also available from http://app.kitchener.ca/opendata/shp/wards.zip
boundaries.register(
    "Kitchener wards",
    domain="Kitchener, ON",
    last_updated=date(2013, 2, 20),
    name_func=boundaries.attr("WardName"),
    id_func=boundaries.attr("WardNumber"),
    authority="Regional Municipality of Waterloo",
    source_url="http://www.regionofwaterloo.ca/en/regionalGovernment/WardBoundaries.asp",
    licence_url="http://www.regionofwaterloo.ca/en/regionalGovernment/OpenDataLicence.asp",
    data_url="http://www.regionofwaterloo.ca/opendatadownloads/WardBoundaries.zip",
    encoding="iso-8859-1",
    metadata={"geographic_code": "3530013"},
    ogr2ogr='''-where "Municipali='Kitchener'"''',
)
コード例 #19
0
from datetime import date

import boundaries

boundaries.register(
    'Oshawa wards',
    domain='Oshawa, ON',
    last_updated=date(2018, 10, 19),
    name_func=lambda f: 'Ward %s' % f.get('WARDNUMBER'),
    id_func=boundaries.attr('WARDNUMBER'),
    authority='City of Oshawa',
    source_url=
    'https://city-oshawa.opendata.arcgis.com/datasets/oshawa-2018-ward-boundaries',
    licence_url=
    'https://map.oshawa.ca/OpenData/Open%20Government%20Licence%20version%202.0%20-%20Oshawa.pdf',
    data_url=
    'https://opendata.arcgis.com/datasets/a9257f99b2d941a3bff928f4a19d6f9d_11.zip',
    encoding='iso-8859-1',
    extra={'division_id': 'ocd-division/country:ca/csd:3518013'},
)
コード例 #20
0
from __future__ import unicode_literals

from datetime import date

import boundaries


boundaries.register('Saskatchewan electoral districts (Representation Act, 2012)',
    singular='Saskatchewan electoral district',
    domain='Saskatchewan',
    last_updated=date(2014, 3, 20),
    name_func=boundaries.dashed_attr('Con_Name'),
    id_func=boundaries.attr('Con_Num'),
    authority='Her Majesty the Queen in Right of Saskatchewan',
    source_url='https://www.geosask.ca/',
    licence_url='https://www.geosask.ca/Portal/jsp/terms_popup.jsp',
    data_url='ftp://*****:*****@ftp.isc.ca/PackagedData/ElectionsSask/2013_Constituency.zip',
    encoding='iso-8859-1',
    extra={'division_id': 'ocd-division/country:ca/province:sk'},
)
コード例 #21
0
from __future__ import unicode_literals

from datetime import date

import boundaries

boundaries.register(
    'Wilmot wards',
    domain='Wilmot, ON',
    last_updated=date(2013, 2, 20),
    name_func=boundaries.attr('WardName'),
    id_func=boundaries.attr('WardNumber'),
    authority='Regional Municipality of Waterloo',
    source_url=
    'http://www.regionofwaterloo.ca/en/regionalGovernment/WardBoundaries.asp',
    licence_url=
    'http://www.regionofwaterloo.ca/en/regionalGovernment/OpenDataLicence.asp',
    data_url=
    'http://www.regionofwaterloo.ca/opendatadownloads/WardBoundaries.zip',
    encoding='iso-8859-1',
    extra={'division_id': 'ocd-division/country:ca/csd:3530020'},
    ogr2ogr='''-where "Municipali='Wilmot'"''',
)
コード例 #22
0
def namer(f):
    import boundaries
    n = boundaries.clean_attr('Descriptio')(f)
    if n.lower().startswith('tracadie'):
        return 'Tracadie—Hillsborough Park'
    elif n.lower().startswith('oleary'):
        return "O'Leary—Inverness"
    return n


boundaries.register(
    'Prince Edward Island electoral districts (2006)',
    singular='Prince Edward Island electoral district',
    domain='Prince Edward Island',
    last_updated=date(2013, 7, 16),
    name_func=namer,
    id_func=boundaries.attr('Name'),
    authority='Her Majesty the Queen in Right of Prince Edward Island',
    source_url='http://www.electionspei.ca/provincial/districts',
    data_url=
    'http://www.electionspei.ca/provincial/details/gis/kml/pei-provincial-districts-all.kml',
    licence_url='http://www.electionspei.ca/apilicense',
    encoding='iso-8859-1',
    extra={'division_id': 'ocd-division/country:ca/province:pe'},
)

# The shapefile from gov.pe.ca has 222 features instead of 27:
# source_url='http://www.gov.pe.ca/gis/index.php3?number=77868&lang=E',
# data_url='http://www.gov.pe.ca/photos/original/prov_elect_dist.SHP.zip',
# licence_url='http://www.gov.pe.ca/gis/license_agreement.php3',
コード例 #23
0
# coding: utf-8
from __future__ import unicode_literals

from datetime import date

import boundaries

# @see http://www.toponymie.gouv.qc.ca/ct/toponymie-municipale/municipalites-arrondissements/arrondissement.aspx
# @see http://www.mamrot.gouv.qc.ca/repertoire-des-municipalites/fiche/arrondissement/?tx_mamrotrepertoire_pi1[order]=asc_nom_mun
boundaries.register('Québec boroughs',
    domain='Québec, QC',
    last_updated=date(2016, 1, 4),
    name_func=lambda f: f.get('NOM').replace('?', '—'),  # m-dash
    id_func=boundaries.attr('CODE'),
    authority='Ville de Québec',
    source_url='http://donnees.ville.quebec.qc.ca/donne_details.aspx?jdid=2',
    licence_url='https://creativecommons.org/licenses/by/4.0/legalcode',
    data_url='http://donnees.ville.quebec.qc.ca/Handler.ashx?id=2&f=SHP',
    encoding='iso-8859-1',
    extra={'division_id': 'ocd-division/country:ca/csd:2423027'},
)
コード例 #24
0
from datetime import date

import boundaries

boundaries.register('Census subdivisions',
    domain='Canada',
    last_updated=date(2011, 11, 28),
    name_func=boundaries.attr('CSDNAME'),
    id_func=boundaries.attr('CSDUID'),  # Census subdivision names are not unique across provinces and territories
    slug_func=boundaries.attr('CSDUID'),
    authority='Her Majesty the Queen in Right of Canada',
    source_url='http://data.gc.ca/data/en/dataset/8b577e89-8c56-4048-b4db-b9d5c753d419',
    licence_url='http://data.gc.ca/eng/open-government-licence-canada',
    data_url='http://www12.statcan.gc.ca/census-recensement/2011/geo/bound-limit/files-fichiers/gcsd000a11a_e.zip',
    encoding='iso-8859-1',
)
コード例 #25
0
import boundaries


def namer(f):
    import boundaries
    n = boundaries.clean_attr('FEDENAME')(f)
    # @see http://www.parl.gc.ca/HousePublications/Publication.aspx?Language=E&Mode=1&DocId=6684609&File=4
    if n == 'Western Arctic':
        return 'Northwest Territories'
    else:
        return n


boundaries.register(
    'Federal electoral districts (2003 Representation Order)',
    singular='Federal electoral district',
    domain='Canada',
    last_updated=date(2011, 11, 28),
    name_func=namer,
    id_func=boundaries.attr('FEDUID'),
    slug_func=boundaries.attr('FEDUID'),
    authority='Her Majesty the Queen in Right of Canada',
    source_url=
    'https://open.canada.ca/data/en/dataset/48f10fb9-78a2-43a9-92ab-354c28d30674',
    licence_url='https://open.canada.ca/en/open-government-licence-canada',
    data_url=
    'https://www12.statcan.gc.ca/census-recensement/2011/geo/bound-limit/files-fichiers/gfed000a11a_e.zip',
    encoding='iso-8859-1',
    extra={'division_id': 'ocd-division/country:ca'},
)
コード例 #26
0
from datetime import date

import boundaries

boundaries.register(
    '',
    domain='',
    last_updated=date(),
    name_func=boundaries.attr(''),
    id_func=boundaries.attr(''),
    authority='',
    source_url='',
    licence_url='',
    data_url='',
    encoding='iso-8859-1',
    metadata={'geographic_code': ''},
)
コード例 #27
0
from __future__ import unicode_literals

from datetime import date

import boundaries

boundaries.register(
    'Northwest Territories electoral districts',
    domain='Northwest Territories',
    last_updated=date(2014, 4, 9),
    name_func=boundaries.attr('ED'),
    id_func=lambda f: int(f.get('EDNWTF_ID')),
    authority='Her Majesty the Queen in Right of Northwest Territories',
    encoding='iso-8859-1',
    extra={'division_id': 'ocd-division/country:ca/territory:nt'},
)
コード例 #28
0
from __future__ import unicode_literals

import re
from datetime import date

import boundaries

boundaries.register(
    'Charlottetown wards',
    domain='Charlottetown, PE',
    last_updated=date(2013, 7, 19),
    name_func=boundaries.attr('NAME'),
    id_func=lambda f: re.sub(r'\D', '', f.get('KEY')),
    authority='Elections Prince Edward Island',
    source_url='http://www.electionspei.ca/municipalities/charlottetown',
    data_url=
    'http://www.electionspei.ca/municipal/details/gis/shp/charlottetown_wards.zip',
    licence_url='http://www.electionspei.ca/apilicense',
    encoding='iso-8859-1',
    extra={'division_id': 'ocd-division/country:ca/csd:1102075'},
)
コード例 #29
0
from __future__ import unicode_literals

from datetime import date

import boundaries

boundaries.register(
    'Brantford wards',
    domain='Brantford, ON',
    last_updated=date(2012, 8, 20),
    name_func=boundaries.attr('WARD_NAME'),
    id_func=boundaries.attr('WARD'),
    authority='City of Brantford',
    encoding='iso-8859-1',
    metadata={'geographic_code': '3529006'},
)
コード例 #30
0
# encoding: utf-8
from datetime import date

import boundaries

boundaries.register(u'San José Council Districts',
    domain=u'San José, CA',
    last_updated=date(2012, 12, 4),
    name_func=lambda f: 'District %s' % f.get('DISTRICTS'),
    id_func=boundaries.attr('DISTRICTS'),
    authority=u'City of San José',
    source_url='http://www.sanjoseca.gov/index.aspx?NID=3308',
    data_url='http://www.sanjoseca.gov/DocumentCenter/View/9266',
    notes='Boundaries change every 10 years according to the census.',
)
コード例 #31
0
from __future__ import unicode_literals

from datetime import date

import boundaries

boundaries.register('Lunenburg districts',
    domain='Lunenburg, NS',
    last_updated=date(2014, 3, 25),
    name_func=lambda f: re.sub(' ?- \d+\Z', '', f.get('Label2')),
    id_func=boundaries.attr('Dletter'),
    authority='Municipality of the District of Lunenburg',
    encoding='iso-8859-1',
    metadata={'geographic_code': '1206001'},
)
コード例 #32
0
from __future__ import unicode_literals

from datetime import date
import re

import boundaries

boundaries.register(
    "Fredericton wards",
    domain="Fredericton, NB",
    last_updated=date(2013, 11, 26),
    name_func=lambda f: re.sub(" / ", "/", f.get("Ward")),
    id_func=boundaries.attr("Ward_Num"),
    authority="City of Fredericton",
    source_url="http://www.fredericton.ca/en/citygovernment/DataMain.asp",
    licence_url="http://www.fredericton.ca/en/citygovernment/TermsOfUse.asp",
    data_url="http://files.fredericton.ca/data/GISData/wards.zip",
    encoding="iso-8859-1",
    metadata={"geographic_code": "1310032"},
)
コード例 #33
0
                    **defaults
                   )

boundaries.register('cd-111',
                    singular='cd-111',
                    file='cd-111/',
                    name_func=tiger_namer,
                    id_func=geoid_tiger_namer,
                    **defaults
                   )

# Zip Code Tabulation Areas
boundaries.register('zcta-14',
                    singular='zcta-14',
                    file='zcta-14/',
                    name_func=boundaries.attr('ZCTA5CE10'),
                    id_func=geoid_tiger_namer,
                    start_date=date(2015, 1, 1),
                    **defaults
                   )

boundaries.register('zcta-13',
                    singular='zcta-13',
                    file='zcta-13/',
                    name_func=boundaries.attr('ZCTA5CE10'),
                    id_func=geoid_tiger_namer,
                    start_date=date(2012, 1, 1),
                    end_date=date(2015, 1, 1),
                    **defaults
                   )
コード例 #34
0
from __future__ import unicode_literals

from datetime import date

import boundaries

boundaries.register(
    'London wards',
    domain='London, ON',
    last_updated=date(2016, 1, 4),
    name_func=lambda f: 'Ward %s' % f.get('WARDS'),
    id_func=boundaries.attr('WARDS'),
    authority='City of London',
    source_url=
    'http://www.london.ca/city-hall/open-data/Pages/Open-Data-Data-Catalogue.aspx',
    licence_url=
    'http://www.london.ca/city-hall/open-data/Pages/OpenData-TermsofUse.aspx',
    data_url=
    'http://apps.london.ca/OpenData/ShapeFiles_Zipped/2010_electoral_wards.zip',
    encoding='iso-8859-1',
    extra={'division_id': 'ocd-division/country:ca/csd:3539036'},
    prj='http://spatialreference.org/ref/epsg/26917/prj/',
)
コード例 #35
0
from datetime import date

import boundaries

boundaries.register(
    'Newfoundland and Labrador electoral districts (2006)',
    singular='Newfoundland and Labrador electoral district',
    domain='Newfoundland and Labrador',
    last_updated=date(2012, 9, 27),
    name_func=boundaries.attr('ELEC_DISTR'),
    authority='Her Majesty the Queen in Right of Newfoundland and Labrador',
    source_url=
    'https://www.elections.gov.nl.ca/elections/ElectoralBoundaries/index.html',
    data_url=
    'https://www.elections.gov.nl.ca/elections/ElectoralBoundaries/Distibution_2011.zip',
    encoding='iso-8859-1',
    extra={'division_id': 'ocd-division/country:ca/province:nl'},
)
コード例 #36
0
from datetime import date

import boundaries

boundaries.register('Halifax districts',
    domain='Halifax, NS',
    last_updated=date(2014, 2, 28),
    name_func=boundaries.attr('DISTNAME'),
    id_func=boundaries.attr('DIST_ID'),
    authority='Halifax Regional Municipality',
    source_url='https://www.halifaxopendata.ca/Zoning/Polling-District/e7u6-by35',
    data_url='https://www.halifaxopendata.ca/api/geospatial/e7u6-by35?method=export&format=Shapefile',
    licence_url='https://www.halifaxopendata.ca/terms',
    encoding='iso-8859-1',
    metadata={'geographic_code': '1209034'},
)
コード例 #37
0
    def __call__(self, feature):
        value = int(feature.get(self.name))
        if value % 100 // 10 == 1:
            suffix = 'th'
        else:
            if value % 10 == 1:
                suffix = 'st'
            elif value % 10 == 2:
                suffix = 'nd'
            elif value % 10 == 3:
                suffix = 'rd'
            else:
                suffix = 'th'
        return u'%d%s District' % (value, suffix)


boundaries.register(
    'Philadelphia Council Districts',
    domain='Philadelphia, PA',
    last_updated=date(2012, 11, 29),
    name_func=ordinal_namer('DIST_NUM'),
    id_func=boundaries.attr('DIST_NUM'),
    authority='City of Philadelphia',
    source_url=
    'http://www.opendataphilly.org/opendata/resource/13/city-council-districts-2000-active/',
    data_url=
    'http://www.pasda.psu.edu/philacity/data/PhiladelphiaCouncilDistricts_2000.zip',
    notes=
    '''Boundaries change in 2016. "Pennsylvania Spatial Data Access (PASDA) is Pennsylvania's official public access geospatial information clearinghouse".''',
)
コード例 #38
0
from datetime import date

import boundaries

boundaries.register('Moncton wards',
    domain='Moncton, NB',
    last_updated=date(2012, 8, 21),
    name_func=lambda f: 'Ward %s' % f.get('WARDNUMB'),
    id_func=boundaries.attr('WARDNUMB'),
    authority='City of Moncton',
    encoding='iso-8859-1',
    metadata={'geographic_code': '1307022'},
)
コード例 #39
0
import re
from datetime import date

import boundaries

boundaries.register('Toronto wards (2010)',
    singular='Toronto ward',
    domain='Toronto, ON',
    last_updated=date(2018, 1, 16),
    name_func=boundaries.attr('NAME'),
    id_func=lambda f: re.sub(r'\A0', '', f.get('SCODE_NAME')),
    authority='City of Toronto',
    source_url='https://www.toronto.ca/city-government/data-research-maps/open-data/open-data-catalogue/#29b6fadf-0bd6-2af9-4a8c-8c41da285ad7',
    licence_url='https://www.toronto.ca/city-government/data-research-maps/open-data/open-data-licence/',
    data_url='http://opendata.toronto.ca/gcc/wards_may2010_wgs84.zip',
    encoding='iso-8859-1',
    extra={'division_id': 'ocd-division/country:ca/csd:3520005'},
)
コード例 #40
0
from datetime import date

import boundaries

boundaries.register('Census subdivisions',
    domain='Canada',
    last_updated=date(2011, 11, 28),
    name_func=boundaries.attr('CSDNAME'),
    id_func=boundaries.attr('CSDUID'),
    slug_func=boundaries.attr('CSDUID'),
    authority='Statistics Canada',
    source_url='http://www12.statcan.gc.ca/census-recensement/2011/geo/bound-limit/bound-limit-eng.cfm',
    licence_url='http://www.statcan.gc.ca/reference/licence-eng.html',
    data_url='http://www12.statcan.gc.ca/census-recensement/2011/geo/bound-limit/files-fichiers/gcsd000a11a_e.zip',
    notes='Census subdivision names are not unique across provinces.',
    encoding='iso-8859-1',
)
コード例 #41
0
from datetime import date

import boundaries


def namer(f):
    import boundaries
    n = boundaries.dashed_attr('CON_NAME')(f)
    if n == 'Regina North East':
        return 'Regina Northeast'
    return n


boundaries.register('Saskatchewan electoral districts (Representation Act, 2002)',
    singular='Saskatchewan electoral district',
    domain='Saskatchewan',
    last_updated=date(2010, 10, 12),
    name_func=namer,
    id_func=boundaries.attr('CON_NUM'),
    authority='Her Majesty the Queen in Right of Saskatchewan',
    source_url='https://www.geosask.ca/',
    licence_url='https://www.geosask.ca/Portal/jsp/terms_popup.jsp',
    encoding='iso-8859-1',
    extra={'division_id': 'ocd-division/country:ca/province:sk'},
)
コード例 #42
0
from __future__ import unicode_literals

from datetime import date

import boundaries

boundaries.register(
    'Calgary wards',
    domain='Calgary, AB',
    last_updated=date(2016, 1, 4),
    name_func=boundaries.clean_attr('LABEL'),
    id_func=boundaries.attr('WARD_NUM'),
    authority='City of Calgary',
    source_url=
    'https://data.calgary.ca/OpenData/Pages/DatasetDetails.aspx?DatasetID=PDC0-99999-99999-00009-P%28CITYonlineDefault%29',
    licence_url='https://data.calgary.ca/OpenData/Pages/TermsofUse.aspx',
    data_url=
    'https://data.calgary.ca/_layouts/OpenData/DownloadDataset.ashx?Format=SHP&DatasetId=PDC0-99999-99999-00009-P(CITYonlineDefault)&VariantId=3(CITYonlineDefault)',
    encoding='iso-8859-1',
    extra={'division_id': 'ocd-division/country:ca/csd:4806016'},
)
コード例 #43
0
from datetime import date

import boundaries

boundaries.register('King wards',
    domain='King, ON',
    last_updated=date(2016, 11, 23),
    name_func=lambda f: 'Ward %s' % f.get('WARD_NUMBE'),
    id_func=boundaries.attr('WARD_NUMBE'),
    authority='Township of King',
    encoding='iso-8859-1',
    extra={'division_id': 'ocd-division/country:ca/csd:3519049'},
    is_valid_func=lambda f: int(f.get('WARD_NUMBE')) != 0,
)
コード例 #44
0
from datetime import date

import boundaries

boundaries.register("St. John's wards",
    domain="St. John's, NL",
    last_updated=date(2012, 8, 17),
    name_func=boundaries.attr('WARDNAME'),
    id_func=boundaries.attr('WARD'),
    authority="City of St. John's",
    encoding='iso-8859-1',
    extra={'division_id': 'ocd-division/country:ca/csd:1001519'},
    is_valid_func=lambda f: int(f.get('WARD')) != 0,
)
コード例 #45
0
from datetime import date

import boundaries

boundaries.register('Federal electoral districts (next election)',
    singular='Federal electoral district',
    domain='Canada',
    last_updated=date(2014, 5, 12),
    name_func=boundaries.clean_attr('ENNAME'),
    id_func=boundaries.attr('FEDNUM'),
    slug_func=boundaries.attr('FEDNUM'),
    authority='Her Majesty the Queen in Right of Canada',
    source_url='http://www.geobase.ca/geobase/en/search.do?produit=fed&language=en',
    licence_url='http://data.gc.ca/eng/open-government-licence-canada',
    data_url='http://ftp2.cits.rncan.gc.ca/pub/geobase/official/fed_cf/shp_eng/fed_cf_CA_2_0_shp_en.zip',
    encoding='iso-8859-1',
    metadata={'geographic_code': '01'},
)
コード例 #46
0
from datetime import date

import boundaries

boundaries.register('Cambridge wards',
    domain='Cambridge, ON',
    last_updated=date(2013, 2, 20),
    name_func=boundaries.attr('WardName'),
    id_func=boundaries.attr('WardNumber'),
    authority='Regional Municipality of Waterloo',
    source_url='http://www.regionofwaterloo.ca/en/regionalGovernment/WardBoundaries.asp',
    licence_url='http://www.regionofwaterloo.ca/en/regionalGovernment/OpenDataLicence.asp',
    data_url='http://www.regionofwaterloo.ca/opendatadownloads/WardBoundaries.zip',
    encoding='iso-8859-1',
    metadata={'geographic_code': '3530010'},
    ogr2ogr='''-where "Municipali='Cambridge'"''',
)
コード例 #47
0
from datetime import date

import boundaries

boundaries.register('Polygons',
    last_updated=date(2000, 1, 1),
    name_func=boundaries.attr('str'),
)
コード例 #48
0
import re
from datetime import date

import boundaries

boundaries.register('Halton Hills wards',
    domain='Halton Hills, ON',
    last_updated=date(2017, 1, 16),
    name_func=boundaries.attr('WARD'),
    id_func=lambda f: re.sub(r'\D+', '', f.get('WARD')),
    authority='Town of Halton Hills',
    encoding='iso-8859-1',
    extra={'division_id': 'ocd-division/country:ca/csd:3524015'},
)
コード例 #49
0
from datetime import date

import boundaries


def namer(f):
    import boundaries

    n = boundaries.clean_attr("ENNAME")(f).replace("\x97", "—").replace("\u0092", "'")  # m-dash

    mappings = {"Gaspsie—Les les-de-la-Madeleine": "Gaspésie—Les Îles-de-la-Madeleine"}

    return mappings.get(n, n)


boundaries.register(
    "Federal electoral districts",
    domain="Canada",
    last_updated=date(2014, 9, 23),
    name_func=namer,
    id_func=boundaries.attr("FEDNUM"),
    slug_func=boundaries.attr("FEDNUM"),
    authority="Her Majesty the Queen in Right of Canada",
    source_url="http://geogratis.gc.ca/api/en/nrcan-rncan/ess-sst/56124851-71fc-4f94-8df2-40f59cd1dd46.html",
    licence_url="http://open.canada.ca/en/open-government-licence-canada",
    data_url="http://ftp2.cits.rncan.gc.ca/pub/geobase/official/fed_cf/shp_eng/fed_cf_CA_2_1_shp_en.zip",
    encoding="iso-8859-1",
    extra={"division_id": "ocd-division/country:ca"},
    notes="Merge electoral districts with multiple features into single features.",
)
コード例 #50
0
from datetime import date

import boundaries

boundaries.register(
    'British Columbia electoral districts (2008 Redistribution)',
    singular='British Columbia electoral district',
    domain='British Columbia',
    last_updated=date(2016, 11, 30),
    name_func=boundaries.attr('ED_NAME'),
    id_func=boundaries.attr('ED_ABBREV'),
    authority='Her Majesty the Queen in Right of British Columbia',
    source_url=
    'https://catalogue.data.gov.bc.ca/dataset/provincial-electoral-districts-electoral-boundaries-redistribution-2008',
    licence_url='https://www.elections.bc.ca/docs/EBC-Open-Data-Licence.pdf',
    data_url=
    'https://catalogue.data.gov.bc.ca/dataset/c864f294-d302-4630-bde3-a0551735b309/resource/dc567bfb-488b-4765-b544-6bd02f61f736/download/edsre2008.zip',
    encoding='iso-8859-1',
    extra={'division_id': 'ocd-division/country:ca/province:bc'},
)
コード例 #51
0
 def test_attr(self):
     self.assertEqual(boundaries.attr('foo')({'foo': 'bar'}), 'bar')
     self.assertEqual(boundaries.attr('foo')({}), None)  # not the case for clean_attr and dashed_attr
コード例 #52
0
# coding: utf-8
from datetime import date

import boundaries

boundaries.register('Quebec electoral districts (2011)',
    singular='Quebec electoral district',
    domain='Quebec',
    last_updated=date(2012, 2, 24),
    name_func=boundaries.clean_attr('NM_CEP'),
    id_func=boundaries.attr('CO_CEP'),
    authority='Directeur général des élections du Québec',
    source_url='https://www.electionsquebec.qc.ca/francais/provincial/carte-electorale/geometrie-des-circonscriptions-provinciales-du-quebec.php',
    licence_url='https://www.electionsquebec.qc.ca/francais/conditions-d-utilisation-de-notre-site-web.php',
    data_url='https://www.electionsquebec.qc.ca/documents/zip/circonscriptions-electorales-2011-shapefile-v2.zip',
    encoding='windows-1252',
    extra={'division_id': 'ocd-division/country:ca/province:qc'},
)
コード例 #53
0

def namer(f):
    import boundaries
    n = boundaries.clean_attr('Descriptio')(f)
    if n.lower().startswith('tracadie'):
        return 'Tracadie—Hillsborough Park'
    elif n.lower().startswith('oleary'):
        return "O'Leary—Inverness"
    return n


boundaries.register('Prince Edward Island electoral districts (2006)',
    singular='Prince Edward Island electoral district',
    domain='Prince Edward Island',
    last_updated=date(2013, 7, 16),
    name_func=namer,
    id_func=boundaries.attr('Name'),
    authority='Her Majesty the Queen in Right of Prince Edward Island',
    source_url='http://www.electionspei.ca/provincial/districts',
    data_url='http://www.electionspei.ca/provincial/details/gis/kml/pei-provincial-districts-all.kml',
    licence_url='http://www.electionspei.ca/apilicense',
    encoding='iso-8859-1',
    extra={'division_id': 'ocd-division/country:ca/province:pe'},
)

# The shapefile from gov.pe.ca has 222 features instead of 27:
# source_url='http://www.gov.pe.ca/gis/index.php3?number=77868&lang=E',
# data_url='http://www.gov.pe.ca/photos/original/prov_elect_dist.SHP.zip',
# licence_url='http://www.gov.pe.ca/gis/license_agreement.php3',
コード例 #54
0
#coding: utf-8
from datetime import date

import boundaries

boundaries.register(u'Québec boroughs',
    domain=u'Québec, QC',
    last_updated=date(2013, 8, 20),
    name_func=boundaries.clean_attr('NOM'),
    id_func=boundaries.attr('CODE'),
    authority=u'Ville de Québec',
    source_url='http://donnees.ville.quebec.qc.ca/donne_details.aspx?jdid=2',
    licence_url='http://donnees.ville.quebec.qc.ca/licence.aspx',
    data_url='http://donnees.ville.quebec.qc.ca/Handler.ashx?id=2&f=SHP',
    encoding='iso-8859-1',
    metadata={'geographic_code': '2423027'},
    prj='http://spatialreference.org/ref/epsg/4326/prj/',
)
コード例 #55
0
from __future__ import unicode_literals

import re
from datetime import date

import boundaries

boundaries.register(
    'Fredericton wards',
    domain='Fredericton, NB',
    last_updated=date(2013, 11, 26),
    name_func=lambda f: re.sub(' / ', '/', f.get('Ward')),
    id_func=boundaries.attr('Ward_Num'),
    authority='City of Fredericton',
    source_url='http://www.fredericton.ca/en/citygovernment/DataMain.asp',
    licence_url='http://www.fredericton.ca/en/citygovernment/TermsOfUse.asp',
    data_url='http://files.fredericton.ca/data/GISData/wards.zip',
    encoding='iso-8859-1',
    extra={'division_id': 'ocd-division/country:ca/csd:1310032'},
)
コード例 #56
0
from datetime import date

import boundaries

boundaries.register('Strathcona County wards',
    domain='Strathcona County, AB',
    last_updated=date(2012, 10, 11),
    name_func=lambda f: 'Ward %s' % f.get('Ward'),
    id_func=boundaries.attr('Ward'),
    authority='Strathcona County',
    notes='We use a shapefile received via email.',
    encoding='iso-8859-1',
)
コード例 #57
0
from __future__ import unicode_literals

import re
from datetime import date

import boundaries

boundaries.register(
    'Clarington wards',
    domain='Clarington, ON',
    last_updated=date(2012, 11, 15),
    name_func=boundaries.attr('WARD'),
    id_func=lambda f: re.sub(r'\D', '', f.get('WARD')),
    authority='Municipality of Clarington',
    encoding='iso-8859-1',
    extra={'division_id': 'ocd-division/country:ca/csd:3518017'},
)