本文整理汇总了Python中django.contrib.gis.utils.LayerMapping方法的典型用法代码示例。如果您正苦于以下问题:Python utils.LayerMapping方法的具体用法?Python utils.LayerMapping怎么用?Python utils.LayerMapping使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.contrib.gis.utils
的用法示例。
在下文中一共展示了utils.LayerMapping方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: state_import
# 需要导入模块: from django.contrib.gis import utils [as 别名]
# 或者: from django.contrib.gis.utils import LayerMapping [as 别名]
def state_import(state_shp, year):
state_mapping = {
'fips_code': 'STATEFP',
'usps_code': 'STUSPS',
'name': 'NAME',
'area_description_code': 'LSAD',
'feature_class_code': 'MTFCC',
'functional_status': 'FUNCSTAT',
'mpoly': 'POLYGON',
}
lm = LayerMapping(State, state_shp, state_mapping)
lm.save(verbose=True)
示例2: county_import
# 需要导入模块: from django.contrib.gis import utils [as 别名]
# 或者: from django.contrib.gis.utils import LayerMapping [as 别名]
def county_import(county_shp, year):
county_mapping = {
'state_fips_code': 'STATEFP',
'fips_code': 'COUNTYFP',
'county_identifier': 'GEOID',
'name': 'NAME',
'name_and_description': 'NAMELSAD',
'legal_statistical_description': 'LSAD',
'fips_55_class_code': 'CLASSFP',
'feature_class_code': 'MTFCC',
'functional_status': 'FUNCSTAT',
'mpoly': 'POLYGON',
}
lm = LayerMapping(County, county_shp, county_mapping, encoding='LATIN1')
lm.save(verbose=True)
示例3: run
# 需要导入模块: from django.contrib.gis import utils [as 别名]
# 或者: from django.contrib.gis.utils import LayerMapping [as 别名]
def run(verbose=True):
lm = LayerMapping(
WorldBorder, world_shp, world_mapping,
transform=False, encoding='iso-8859-1',
)
lm.save(strict=True, verbose=verbose)
示例4: test05_geography_layermapping
# 需要导入模块: from django.contrib.gis import utils [as 别名]
# 或者: from django.contrib.gis.utils import LayerMapping [as 别名]
def test05_geography_layermapping(self):
"Testing LayerMapping support on models with geography fields."
# There is a similar test in `layermap` that uses the same data set,
# but the County model here is a bit different.
from django.contrib.gis.utils import LayerMapping
# Getting the shapefile and mapping dictionary.
shp_path = os.path.realpath(os.path.join(os.path.dirname(upath(__file__)), '..', 'data'))
co_shp = os.path.join(shp_path, 'counties', 'counties.shp')
co_mapping = {'name' : 'Name',
'state' : 'State',
'mpoly' : 'MULTIPOLYGON',
}
# Reference county names, number of polygons, and state names.
names = ['Bexar', 'Galveston', 'Harris', 'Honolulu', 'Pueblo']
num_polys = [1, 2, 1, 19, 1] # Number of polygons for each.
st_names = ['Texas', 'Texas', 'Texas', 'Hawaii', 'Colorado']
lm = LayerMapping(County, co_shp, co_mapping, source_srs=4269, unique='name')
lm.save(silent=True, strict=True)
for c, name, num_poly, state in zip(County.objects.order_by('name'), names, num_polys, st_names):
self.assertEqual(4326, c.mpoly.srid)
self.assertEqual(num_poly, len(c.mpoly))
self.assertEqual(name, c.name)
self.assertEqual(state, c.state)
示例5: load_world
# 需要导入模块: from django.contrib.gis import utils [as 别名]
# 或者: from django.contrib.gis.utils import LayerMapping [as 别名]
def load_world(verbose=True):
WorldBorder.objects.all().delete()
lm = LayerMapping(WorldBorder, world_shp, world_mapping, transform=False, encoding='iso-8859-1')
lm.save(strict=True, verbose=verbose)
示例6: run
# 需要导入模块: from django.contrib.gis import utils [as 别名]
# 或者: from django.contrib.gis.utils import LayerMapping [as 别名]
def run(verbose=True):
yangu = LayerMapping(Bus_Stops, stop_shp, bus_stops_mapping, )
yangu.save(strict=True, verbose=verbose)