Created
November 1, 2011 21:10
-
-
Save albertsun/1331920 to your computer and use it in GitHub Desktop.
census data models.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib.gis.db import models | |
# generated by running ogrinspect against shapefiles | |
# ./manage.py ogrinspect ../state_tabblock_shapefiles/tl_2010_01_tabblock10/tl_2010_01_tabblock10.shp CensusBlock --srid=4326 --mapping --multi | |
# ./manage.py ogrinspect ../state_tract_shapefiles/tl_2010_01_tract10/tl_2010_01_tract10.shp CensusTract --srid=4326 --mapping --multi | |
class CensusBlock(models.Model): | |
statefp10 = models.CharField(max_length=2) | |
countyfp10 = models.CharField(max_length=3) | |
tractce10 = models.CharField(max_length=6) | |
blockce10 = models.CharField(max_length=4) | |
geoid10 = models.CharField(max_length=15, primary_key=True) | |
name10 = models.CharField(max_length=10) | |
mtfcc10 = models.CharField(max_length=5) | |
ur10 = models.CharField(max_length=1) | |
uace10 = models.CharField(max_length=5) | |
funcstat10 = models.CharField(max_length=1) | |
aland10 = models.DecimalField(max_digits=14, decimal_places=0) | |
awater10 = models.DecimalField(max_digits=14, decimal_places=0) | |
intptlat10 = models.CharField(max_length=11) | |
intptlon10 = models.CharField(max_length=12) | |
the_geom = models.MultiPolygonField(srid=4326) | |
objects = models.GeoManager() | |
def __unicode__(self): | |
return u'<'+self.__module__+' CensusBlock: '+unicode(self.geoid10)+')>' | |
def __repr__(self): | |
return unicode(self).encode('utf-8') | |
def __str__(self): | |
return "Block "+str(self.geoid10) | |
class Meta: | |
db_table = u'censusblocks' | |
unique_together = ("statefp10", "countyfp10", "tractce10", "blockce10") | |
verbose_name = u'Census Block' | |
verbose_name_plural = u'Census Blocks' | |
class CensusTract(models.Model): | |
statefp10 = models.CharField(max_length=2) | |
countyfp10 = models.CharField(max_length=3) | |
tractce10 = models.CharField(max_length=6) | |
geoid10 = models.CharField(max_length=11, primary_key=True) | |
name10 = models.CharField(max_length=7) | |
namelsad10 = models.CharField(max_length=20) | |
mtfcc10 = models.CharField(max_length=5) | |
funcstat10 = models.CharField(max_length=1) | |
aland10 = models.FloatField() | |
awater10 = models.FloatField() | |
intptlat10 = models.CharField(max_length=11) | |
intptlon10 = models.CharField(max_length=12) | |
the_geom = models.MultiPolygonField(srid=4326) | |
objects = models.GeoManager() | |
def __unicode__(self): | |
return u'<'+self.__module__+' CensusTract: '+unicode(self.geoid10)+')>' | |
def __repr__(self): | |
return unicode(self).encode('utf-8') | |
def __str__(self): | |
return "Tract "+str(self.geoid10) | |
class Meta: | |
db_table = u'censustracts' | |
unique_together = ("statefp10", "countyfp10", "tractce10") | |
verbose_name = u'Census Tract' | |
verbose_name_plural = u'Census Tracts' | |
class CensusCounty(models.Model): | |
statefp10 = models.CharField(max_length=2) | |
countyfp10 = models.CharField(max_length=3) | |
countyns10 = models.CharField(max_length=8) | |
geoid10 = models.CharField(max_length=5, primary_key=True) | |
name10 = models.CharField(max_length=100) | |
namelsad10 = models.CharField(max_length=100) | |
lsad10 = models.CharField(max_length=2) | |
classfp10 = models.CharField(max_length=2) | |
mtfcc10 = models.CharField(max_length=5) | |
csafp10 = models.CharField(max_length=3) | |
cbsafp10 = models.CharField(max_length=5) | |
metdivfp10 = models.CharField(max_length=5) | |
funcstat10 = models.CharField(max_length=1) | |
aland10 = models.FloatField() | |
awater10 = models.FloatField() | |
intptlat10 = models.CharField(max_length=11) | |
intptlon10 = models.CharField(max_length=12) | |
the_geom = models.MultiPolygonField(srid=4326) | |
objects = models.GeoManager() | |
def __unicode__(self): | |
return u'<'+self.__module__+' CensusCounty: '+unicode(self.geoid10)+')>' | |
def __repr__(self): | |
return unicode(self).encode('utf-8') | |
def __str__(self): | |
return "Tract "+str(self.geoid10) | |
class Meta: | |
db_table = u'censuscounties' | |
unique_together = ("statefp10", "countyfp10") | |
verbose_name = u'Census County' | |
verbose_name_plural = u'Census Counties' | |
class DataBlock(CensusBlock): | |
#geoid10 = models.OneToOneField(CensusBlock, to_field='geoid10', parent_link=True) #0 | |
totpop = models.IntegerField(verbose_name="Total Population") #46 | |
totpop_wnh = models.IntegerField(verbose_name="Total Population, White Non-Hispanic") #77 | |
totpop_h = models.IntegerField(verbose_name="Total Population, Hispanic") #75 | |
totpop_black = models.IntegerField(verbose_name="Total Population, Black") #48 | |
totpop_na = models.IntegerField(verbose_name="Total Population, Native American") #49 | |
totpop_a = models.IntegerField(verbose_name="Total Population, Asian") #50 | |
totpop_hi = models.IntegerField(verbose_name="Total Population, Hawaiian/Pacific Islander") #51 | |
totpop_other = models.IntegerField(verbose_name="Total Population, Other") #82 | |
totpop_multiracial = models.IntegerField(verbose_name="Total Population, Other") #99 | |
vap = models.IntegerField(verbose_name="Voting Age Population") #112 | |
vap_wnh = models.IntegerField(verbose_name="Voting Age Population, White Non-Hispanic") #143 | |
vap_h = models.IntegerField(verbose_name="Voting Age Population, Hispanic") #141 | |
vap_black = models.IntegerField(verbose_name="Voting Age Population, Black") #114 | |
vap_na = models.IntegerField(verbose_name="Voting Age Population, Native American") #115 | |
vap_a = models.IntegerField(verbose_name="Voting Age Population, Asian") #116 | |
vap_hi = models.IntegerField(verbose_name="Voting Age Population, Hawaiian") #117 | |
vap_other = models.IntegerField(verbose_name="Voting Age Population, Other") #148 | |
vap_multiracial = models.IntegerField(verbose_name="Voting Age Population, Other") #165 | |
objects = models.GeoManager() | |
def __unicode__(self): | |
return u'<'+self.__module__+' DataBlock: '+unicode(self.geoid10)+')>' | |
def __repr__(self): | |
return unicode(self).encode('utf-8') | |
def __str__(self): | |
return "DataBlock "+str(self.geoid10) | |
class Meta: | |
db_table = u'datablocks' | |
verbose_name = u'Block Data' | |
verbose_name_plural = u'Blocks Data' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment