当前位置: 首页>>代码示例>>Python>>正文


Python utils.LayerMapping方法代码示例

本文整理汇总了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) 
开发者ID:jlillest,项目名称:geodjango-tigerleaflet,代码行数:14,代码来源:load_states.py

示例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) 
开发者ID:jlillest,项目名称:geodjango-tigerleaflet,代码行数:17,代码来源:load_counties.py

示例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) 
开发者ID:goldtime1989,项目名称:mapWithDjango,代码行数:8,代码来源:load.py

示例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) 
开发者ID:VirtualPlants,项目名称:tissuelab,代码行数:29,代码来源:tests.py

示例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) 
开发者ID:damianmoore,项目名称:photo-manager,代码行数:7,代码来源:load.py

示例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) 
开发者ID:joehene,项目名称:djangoleaflet,代码行数:5,代码来源:loadbusstops.py


注:本文中的django.contrib.gis.utils.LayerMapping方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。