Thin Python wrapper for the US Census Geocoder
Project description
Python 2 and 3 wrapper for the US Census Geocoder API.
Basic example:
from censusgeocode import CensusGeocode
cg = CensusGeocode()
cg.coordinates(x=-76, y=41)
cg.onelineaddress('1600 Pennsylvania Avenue, Washington, DC')
cg.address('1600 Pennsylvania Avenue', city='Washington', state='DC', zipcode='22052')
Use the returntype keyword to specify ‘locations’ or ‘geographies’. Geographies is the default.
cg.onelineaddress('1600 Pennsylvania Avenue, Washington, DC', returntype='locations')
Queries return a CensusResult object, which is basically a Python list with an extra ‘input’ property, which the Census returns to tell you how they interpreted your request.
>>> result = cg.coordinates(x=-76, y=41)
>>> result.input
{u'vintage': {u'vintageName': u'Current_Current', u'id': u'4', u'vintageDescription': u'Current Vintage - Current Benchmark', u'isDefault': True}, u'benchmark': {u'benchmarkName': u'Public_AR_Current', u'id': u'4', u'isDefault': False, u'benchmarkDescription': u'Public Address Ranges - Current Benchmark'}, u'location': {u'y': 41.0, u'x': -76.0}}
>>> result
[{
'2010 Census Blocks': [{
'AREALAND': 1409023,
'AREAWATER': 0,
'BASENAME': '1045',
'BLKGRP': '1',
'BLOCK': '1045',
'CENTLAT': '+40.9957436',
'CENTLON': '-076.0089338',
'COUNTY': '079',
'FUNCSTAT': 'S',
'GEOID': '420792166001045',
'INTPTLAT': '+40.9957436',
'INTPTLON': '-076.0089338',
'LSADC': 'BK',
'LWBLKTYP': 'L',
'MTFCC': 'G5040',
'NAME': 'Block 1045',
'OBJECTID': 9940449,
'OID': 210404020212114,
'STATE': '42',
'SUFFIX': '',
'TRACT': '216600'
}],
'Census Tracts': [{
'AREALAND': 86404594,
'AREAWATER': 650526,
'BASENAME': '2166',
'CENTLAT': '+41.0361462',
'CENTLON': '-075.9801252',
'COUNTY': '079',
'FUNCSTAT': 'S',
'GEOID': '42079216600',
'INTPTLAT': '+41.0379841',
'INTPTLON': '-075.9743749',
'LSADC': 'CT',
'MTFCC': 'G5020',
'NAME': 'Census Tract 2166',
'OBJECTID': 61245,
'OID': 20790277158250,
'STATE': '42',
'TRACT': '216600'
}],
'Counties': [{
'AREALAND': 2305974186,
'AREAWATER': 41240020,
'BASENAME': 'Luzerne',
'CENTLAT': '+41.1768961',
'CENTLON': '-075.9890400',
'COUNTY': '079',
'COUNTYCC': 'H1',
'COUNTYNS': '01209183',
'FUNCSTAT': 'A',
'GEOID': '42079',
'INTPTLAT': '+41.1727868',
'INTPTLON': '-075.9760345',
'LSADC': '06',
'MTFCC': 'G4020',
'NAME': 'Luzerne County',
'OBJECTID': 866,
'OID': 27590277115518,
'STATE': '42'
}],
'States': [{
'AREALAND': 115884236236,
'AREAWATER': 3395797284,
'BASENAME': 'Pennsylvania',
'CENTLAT': '+40.9011252',
'CENTLON': '-077.8369164',
'DIVISION': '2',
'FUNCSTAT': 'A',
'GEOID': '42',
'INTPTLAT': '+40.9024957',
'INTPTLON': '-077.8334514',
'LSADC': '00',
'MTFCC': 'G4000',
'NAME': 'Pennsylvania',
'OBJECTID': 37,
'OID': 27490163788605,
'REGION': '1',
'STATE': '42',
'STATENS': '01779798',
'STUSAB': 'PA'
}]
}]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
censusgeocode-0.2.0.tar.gz
(4.2 kB
view details)
Built Distribution
File details
Details for the file censusgeocode-0.2.0.tar.gz
.
File metadata
- Download URL: censusgeocode-0.2.0.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 30012dbddb5e6a90a9251f6518140a064d1b5ffff66dfdad13c5408b7af8eda2 |
|
MD5 | e00238e35325e5e5ea6cfb9ae9205466 |
|
BLAKE2b-256 | 944062a31f57e914716941e95bbd26e5b2ae6275567267c3c500d2c6c307a514 |
File details
Details for the file censusgeocode-0.2.0-py2-none-any.whl
.
File metadata
- Download URL: censusgeocode-0.2.0-py2-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b0af930171af69473563bf5cc34faa8b33566661d7d6886aa2cca6724955b7c0 |
|
MD5 | 602382012da480b73539064ba9320b58 |
|
BLAKE2b-256 | f563ca27d2864e0aa351abb094bf48f2585d76e5ee90b3cdfd5088b14a2a0b54 |