• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python utilities.standard_data_path函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中safe.test.utilities.standard_data_path函数的典型用法代码示例。如果您正苦于以下问题:Python standard_data_path函数的具体用法?Python standard_data_path怎么用?Python standard_data_path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了standard_data_path函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_run

    def test_run(self):
        function = ClassifiedRasterHazardBuildingFunction.instance()

        hazard_path = standard_data_path(
            'hazard', 'classified_hazard.tif')
        exposure_path = standard_data_path('exposure', 'small_building.shp')
        hazard_layer = read_layer(hazard_path)
        exposure_layer = read_layer(exposure_path)

        function.hazard = SafeLayer(hazard_layer)
        function.exposure = SafeLayer(exposure_layer)
        function.run_analysis()
        impact_layer = function.impact
        impact_data = impact_layer.get_data()

        # Count
        expected_impact = {
            'Not affected': 5,
            'Low hazard zone': 2,
            'Medium hazard zone': 9,
            'High hazard zone': 5
        }

        result_impact = {}
        for impact_feature in impact_data:
            hazard_class = impact_feature[function.target_field]
            if hazard_class in result_impact:
                result_impact[hazard_class] += 1
            else:
                result_impact[hazard_class] = 1
        self.assertDictEqual(expected_impact, result_impact)
开发者ID:easmetz,项目名称:inasafe,代码行数:31,代码来源:test_classified_raster_hazard_building.py


示例2: test_run

    def test_run(self):
        """TestClassifiedPolygonPopulationFunction: Test running the IF."""
        generic_polygon_path = standard_data_path(
            'hazard', 'classified_generic_polygon.shp')
        population_path = standard_data_path(
            'exposure', 'pop_binary_raster_20_20.asc')

        generic_polygon_layer = read_layer(generic_polygon_path)
        population_layer = read_layer(population_path)

        impact_function = ClassifiedPolygonHazardPopulationFunction.instance()
        impact_function.hazard = SafeLayer(generic_polygon_layer)
        impact_function.exposure = SafeLayer(population_layer)
        impact_function.run()
        impact_layer = impact_function.impact
        # Check the question
        expected_question = ('In each of the hazard zones how many people '
                             'might be impacted.')
        message = 'The question should be %s, but it returns %s' % (
            expected_question, impact_function.question)
        self.assertEqual(expected_question, impact_function.question, message)
        # Count by hand
        expected_affected_population = 181
        result = numpy.nansum(impact_layer.get_data())
        self.assertEqual(expected_affected_population, result, message)
开发者ID:easmetz,项目名称:inasafe,代码行数:25,代码来源:test_classified_polygon_population.py


示例3: test_run

    def test_run(self):
        function = AshRasterPopulationFunction.instance()

        hazard_path = standard_data_path('hazard', 'ash_raster_wgs84.tif')
        exposure_path = standard_data_path(
            'exposure', 'pop_binary_raster_20_20.asc')
        # We need clipping for both layers to be in the same dimension
        clipped_hazard, clipped_exposure = clip_layers(
            hazard_path, exposure_path)

        hazard_layer = read_layer(clipped_hazard.source())
        exposure_layer = read_layer(clipped_exposure.source())

        # Let's set the extent to the hazard extent
        function.hazard = SafeLayer(hazard_layer)
        function.exposure = SafeLayer(exposure_layer)
        function.run()
        impact = function.impact
        expected = [
            [u'Population in very low hazard zone', 0],
            [u'Population in medium hazard zone', 1374],
            [u'Population in high hazard zone', 20],
            [u'Population in very high hazard zone', 0],
            [u'Population in low hazard zone', 8443],
            [u'Total affected population', 9837],
            [u'Unaffected population', 0],
            [u'Total population', 9837],
            [u'Population needing evacuation <sup>1</sup>', 9837]
        ]
        self.assertListEqual(
            expected, impact.impact_data['impact summary']['fields'])
开发者ID:easmetz,项目名称:inasafe,代码行数:31,代码来源:test_ash_raster_population.py


示例4: test_run

    def test_run(self):
        function = ContinuousHazardPopulationFunction.instance()

        hazard_path = standard_data_path(
            'hazard', 'continuous_flood_20_20.asc')
        exposure_path = standard_data_path(
            'exposure', 'pop_binary_raster_20_20.asc')
        hazard_layer = read_layer(hazard_path)
        exposure_layer = read_layer(exposure_path)

        function.hazard = SafeLayer(hazard_layer)
        function.exposure = SafeLayer(exposure_layer)
        function.run()
        impact = function.impact

        # print "keywords", keywords
        keywords = impact.get_keywords()
        total_needs_full = keywords['total_needs']
        total_needs_weekly = OrderedDict([
            [x['table name'], x['amount']] for x in
            total_needs_full['weekly']
        ])
        total_needs_single = OrderedDict([
            [x['table name'], x['amount']] for x in
            total_needs_full['single']
        ])

        self.assertEqual(total_needs_weekly['Rice [kg]'], 336)
        self.assertEqual(total_needs_weekly['Drinking Water [l]'], 2100)
        self.assertEqual(total_needs_weekly['Clean Water [l]'], 8040)
        self.assertEqual(total_needs_weekly['Family Kits'], 24)
        self.assertEqual(total_needs_single['Toilets'], 6)
开发者ID:easmetz,项目名称:inasafe,代码行数:32,代码来源:test_continuous_hazard_population.py


示例5: test_is_polygonal_layer

    def test_is_polygonal_layer(self):
        """Test we can get the correct attributes back"""
        # Polygon layer
        layer = clone_shp_layer(
            name='district_osm_jakarta',
            include_keywords=True,
            source_directory=standard_data_path('boundaries'))
        message = 'isPolygonLayer, %s layer should be polygonal' % layer
        self.assertTrue(is_polygon_layer(layer), message)

        # Point layer
        layer = clone_shp_layer(
            name='volcano_point',
            include_keywords=True,
            source_directory=standard_data_path('hazard'))
        message = '%s layer should be polygonal' % layer
        self.assertFalse(is_polygon_layer(layer), message)

        layer = clone_raster_layer(
            name='padang_tsunami_mw8',
            extension='.tif',
            include_keywords=True,
            source_directory=standard_data_path('hazard')
        )
        message = ('%s raster layer should not be polygonal' % layer)
        self.assertFalse(is_polygon_layer(layer), message)
开发者ID:easmetz,项目名称:inasafe,代码行数:26,代码来源:test_gis.py


示例6: test_run

    def test_run(self):
        function = FloodRasterRoadsFunction.instance()

        hazard_path = standard_data_path(
            'hazard', 'continuous_flood_20_20.asc')
        exposure_path = standard_data_path('exposure', 'roads.shp')
        # noinspection PyCallingNonCallable
        hazard_layer = QgsRasterLayer(hazard_path, 'Flood')
        # noinspection PyCallingNonCallable
        exposure_layer = QgsVectorLayer(exposure_path, 'Roads', 'ogr')

        # Let's set the extent to the hazard extent
        extent = hazard_layer.extent()
        rect_extent = [
            extent.xMinimum(), extent.yMaximum(),
            extent.xMaximum(), extent.yMinimum()]
        function.hazard = SafeLayer(hazard_layer)
        function.exposure = SafeLayer(exposure_layer)
        function.requested_extent = rect_extent
        function.run()
        impact = function.impact

        keywords = impact.get_keywords()
        self.assertEquals(function.target_field, keywords['target_field'])
        expected_inundated_feature = 182
        count = sum(impact.get_data(attribute=function.target_field))
        self.assertEquals(count, expected_inundated_feature)
开发者ID:easmetz,项目名称:inasafe,代码行数:27,代码来源:test_flood_raster_roads_function.py


示例7: test_run

    def test_run(self):
        """TestVolcanoPointBuildingFunction: Test running the IF."""
        volcano_path = standard_data_path('hazard', 'volcano_point.shp')
        building_path = standard_data_path('exposure', 'buildings.shp')

        hazard_layer = read_layer(volcano_path)
        exposure_layer = read_layer(building_path)

        impact_function = VolcanoPointBuildingFunction.instance()
        impact_function.hazard = SafeLayer(hazard_layer)
        impact_function.exposure = SafeLayer(exposure_layer)
        impact_function._prepare()
        impact_function.run()
        impact_layer = impact_function.impact

        # Check the question
        expected_question = (
            'In the event of volcano point how many buildings might be '
            'affected')
        message = 'The question should be %s, but it returns %s' % (
            expected_question, impact_function.question)
        self.assertEqual(expected_question, impact_function.question, message)

        # The buildings should all be categorised into 3000 zone
        zone_sum = sum(impact_layer.get_data(
            attribute=impact_function.target_field))
        expected_sum = 3 * 181
        message = 'Expecting %s, but it returns %s' % (expected_sum, zone_sum)
        self.assertEqual(zone_sum, expected_sum, message)
开发者ID:easmetz,项目名称:inasafe,代码行数:29,代码来源:test_volcano_point_building.py


示例8: test_run_point_exposure

    def test_run_point_exposure(self):
        """Run the IF for point exposure.

        See https://github.com/AIFDR/inasafe/issues/2156.
        """
        generic_polygon_path = standard_data_path(
            'hazard', 'classified_generic_polygon.shp')
        building_path = standard_data_path('exposure', 'building-points.shp')

        hazard_layer = QgsVectorLayer(generic_polygon_path, 'Hazard', 'ogr')
        exposure_layer = QgsVectorLayer(building_path, 'Buildings', 'ogr')

        # Let's set the extent to the hazard extent
        extent = hazard_layer.extent()
        rect_extent = [
            extent.xMinimum(), extent.yMaximum(),
            extent.xMaximum(), extent.yMinimum()]

        impact_function = ClassifiedPolygonHazardBuildingFunction.instance()
        impact_function.hazard = SafeLayer(hazard_layer)
        impact_function.exposure = SafeLayer(exposure_layer)
        impact_function.requested_extent = rect_extent
        impact_function.run()
        impact_layer = impact_function.impact

        # Check the question
        expected_question = ('In each of the hazard zones how many buildings '
                             'might be affected.')
        message = 'The question should be %s, but it returns %s' % (
            expected_question, impact_function.question)
        self.assertEqual(expected_question, impact_function.question, message)

        zone_sum = impact_layer.get_data(
            attribute=impact_function.target_field)
        high_zone_count = zone_sum.count('High Hazard Zone')
        medium_zone_count = zone_sum.count('Medium Hazard Zone')
        low_zone_count = zone_sum.count('Low Hazard Zone')
        # The result
        expected_high_count = 12
        expected_medium_count = 172
        expected_low_count = 3
        message = 'Expecting %s for High Hazard Zone, but it returns %s' % (
            high_zone_count, expected_high_count)
        self.assertEqual(high_zone_count, expected_high_count, message)

        message = 'Expecting %s for Medium Hazard Zone, but it returns %s' % (
            expected_medium_count, medium_zone_count)
        self.assertEqual(medium_zone_count, expected_medium_count, message)

        message = 'Expecting %s for Low Hazard Zone, but it returns %s' % (
            expected_low_count, low_zone_count)
        self.assertEqual(expected_low_count, low_zone_count, message)
开发者ID:easmetz,项目名称:inasafe,代码行数:52,代码来源:test_classified_polygon_building.py


示例9: test_raster_to_vector_and_line_intersection

    def test_raster_to_vector_and_line_intersection(self):
        """Test the core part of the analysis.

        1. Test creation of spatial index of flood cells
        2. Test intersection of flood cells with roads layer
        """

        raster_name = standard_data_path(
            'hazard',
            'tsunami_wgs84.tif')
        exposure_name = standard_data_path(
            'exposure',
            'roads_osm_4326.shp')

        raster = QgsRasterLayer(raster_name, 'Flood')
        exposure = QgsVectorLayer(exposure_name, 'Exposure', 'ogr')

        ranges = OrderedDict()
        ranges[0] = [0, 1]
        ranges[1] = [1, 2]
        ranges[2] = [2, 100]
        index, flood_cells_map = _raster_to_vector_cells(
            raster, ranges, exposure.crs())

        self.assertEqual(len(flood_cells_map), 4198)
        rect_with_all_cells = raster.extent()
        rect_with_4_cells = QgsRectangle(106.824, -6.177, 106.825, -6.179)
        rect_with_0_cells = QgsRectangle(106.818, -6.168, 106.828, -6.175)
        self.assertEqual(len(index.intersects(rect_with_all_cells)), 4198)
        self.assertEqual(len(index.intersects(rect_with_4_cells)), 43)
        self.assertEqual(len(index.intersects(rect_with_0_cells)), 504)

        layer = create_layer(exposure)
        new_field = QgsField('flooded', QVariant.Int)
        layer.dataProvider().addAttributes([new_field])

        request = QgsFeatureRequest()
        _intersect_lines_with_vector_cells(
            exposure, request, index, flood_cells_map, layer, 'flooded')

        feature_count = layer.featureCount()
        self.assertEqual(feature_count, 388)

        flooded = 0
        iterator = layer.getFeatures()
        for feature in iterator:
            attributes = feature.attributes()
            if attributes[3] == 1:
                flooded += 1
        self.assertEqual(flooded, 40)
开发者ID:easmetz,项目名称:inasafe,代码行数:50,代码来源:test_tsunami_raster_road.py


示例10: setUp

    def setUp(self):
        self.keyword_io = KeywordIO()

        # SQLite Layer
        uri = QgsDataSourceURI()
        sqlite_building_path = standard_data_path(
            'exposure', 'exposure.sqlite')
        uri.setDatabase(sqlite_building_path)
        uri.setDataSource('', 'buildings_osm_4326', 'Geometry')
        self.sqlite_layer = QgsVectorLayer(
            uri.uri(), 'OSM Buildings', 'spatialite')
        self.expected_sqlite_keywords = {
            'datatype': 'OSM'
        }

        # Raster Layer keywords
        hazard_path = standard_data_path('hazard', 'tsunami_wgs84.tif')
        self.raster_layer, _ = load_layer(hazard_path)
        self.expected_raster_keywords = {
            'hazard_category': 'single_event',
            'title': 'Generic Continuous Flood',
            'hazard': 'flood',
            'continuous_hazard_unit': 'generic',
            'layer_geometry': 'raster',
            'layer_purpose': 'hazard',
            'layer_mode': 'continuous',
            'keyword_version': '3.5'
        }

        # Vector Layer keywords
        vector_path = standard_data_path('exposure', 'buildings_osm_4326.shp')
        self.vector_layer, _ = load_layer(vector_path)
        self.expected_vector_keywords = {
            'keyword_version': '3.5',
            'structure_class_field': 'FLOODED',
            'value_mapping': {},
            'title': 'buildings_osm_4326',
            'layer_geometry': 'polygon',
            'layer_purpose': 'exposure',
            'layer_mode': 'classified',
            'exposure': 'structure',
        }
        # Keyword less layer
        keywordless_path = standard_data_path('other', 'keywordless_layer.shp')
        self.keywordless_layer, _ = load_layer(keywordless_path)
        # Keyword file
        self.keyword_path = standard_data_path(
            'exposure', 'buildings_osm_4326.xml')
开发者ID:easmetz,项目名称:inasafe,代码行数:48,代码来源:test_keyword_io.py


示例11: test_converting

    def test_converting(self):
        """Test converting grif file to tiff."""
        dialog = ShakemapConverterDialog(PARENT, IFACE)
        dialog.use_output_default.setEnabled(False)
        grid_path = standard_data_path(
            'hazard',
            'shake_data',
            '20131105060809',
            'output',
            'grid.xml')
        output_raster = unique_filename(
            prefix='result_grid',
            suffix='.tif',
            dir=temp_dir('test'))
        dialog.load_result.setEnabled(True)
        dialog.load_result.setChecked(False)
        dialog.input_path.setText(grid_path)
        dialog.nearest_mode.setChecked(True)
        dialog.output_path.setText(output_raster)
        button = dialog.button_box.button(QDialogButtonBox.Ok)
        button.click()

        msg = 'Raster is not created'
        output_path = '%s-nearest.tif' % output_raster[:-4]
        self.assertTrue(os.path.exists(output_path), msg)
开发者ID:inasafe,项目名称:inasafe,代码行数:25,代码来源:test_shakemap_converter_dialog.py


示例12: test_relative_path

    def test_relative_path(self):
        """Test we calculate the relative paths correctly when saving scenario.
        """
        result, message = setup_scenario(
            self.DOCK,
            hazard='Classified Flood',
            exposure='Population')
        self.assertTrue(result, message)
        fake_dir = standard_data_path()
        scenario_file = unique_filename(
            prefix='scenarioTest', suffix='.txt', dir=fake_dir)
        exposure_layer = self.DOCK.get_exposure_layer().publicSource()
        hazard_layer = self.DOCK.get_hazard_layer().publicSource()

        relative_exposure = self.save_scenario_dialog.relative_path(
            scenario_file, exposure_layer)
        relative_hazard = self.save_scenario_dialog.relative_path(
            scenario_file, hazard_layer)

        if 'win32' in sys.platform:
            # windows
            self.assertEqual(
                'exposure\\pop_binary_raster_20_20.asc',
                relative_exposure)
            self.assertEqual(
                'hazard\\classified_flood_20_20.asc',
                relative_hazard)

        else:
            self.assertEqual(
                'exposure/pop_binary_raster_20_20.asc',
                relative_exposure)
            self.assertEqual(
                'hazard/classified_flood_20_20.asc',
                relative_hazard)
开发者ID:timlinux,项目名称:inasafe,代码行数:35,代码来源:test_save_scenario.py


示例13: setUp

 def setUp(self):
     """Setup before each test."""
     # Download files (which are local files) to realtime-test temp folder
     local_path = os.path.join(temp_dir('realtime-test'))
     shake_data = standard_data_path('hazard', 'shake_data', SHAKE_ID)
     shutil.copytree(
         shake_data, os.path.join(local_path, 'shakemaps', SHAKE_ID))
开发者ID:easmetz,项目名称:inasafe,代码行数:7,代码来源:test_shake_data.py


示例14: test_update_keywords

 def test_update_keywords(self):
     """Test append file keywords with update_keywords method."""
     self.maxDiff = None
     layer = clone_raster_layer(
         name='tsunami_wgs84',
         extension='.tif',
         include_keywords=True,
         source_directory=standard_data_path('hazard'))
     new_keywords = {
         'hazard_category': 'multiple_event'
     }
     self.keyword_io.update_keywords(layer, new_keywords)
     keywords = self.keyword_io.read_keywords(layer)
     expected_keywords = {
         'hazard_category': 'multiple_event',
         'title': 'Tsunami',
         'hazard': 'tsunami',
         'continuous_hazard_unit': 'metres',
         'layer_geometry': 'raster',
         'layer_purpose': 'hazard',
         'layer_mode': 'continuous',
         'keyword_version': inasafe_keyword_version
     }
     expected_keywords = {
         k: get_unicode(v) for k, v in expected_keywords.iteritems()
     }
     self.assertDictEqual(keywords, expected_keywords)
开发者ID:easmetz,项目名称:inasafe,代码行数:27,代码来源:test_keyword_io.py


示例15: test_is_polygonal_layer

    def test_is_polygonal_layer(self):
        """Test we can get the correct attributes back"""
        # Polygon layer
        layer = load_test_vector_layer(
            'aggregation',
            'district_osm_jakarta.geojson',
            clone=True
        )
        message = 'isPolygonLayer, %s layer should be polygonal' % layer
        self.assertTrue(is_polygon_layer(layer), message)

        # Point layer
        layer = load_test_vector_layer('hazard', 'volcano_point.geojson')
        message = '%s layer should be polygonal' % layer
        self.assertFalse(is_polygon_layer(layer), message)

        # Raster layer
        layer = clone_raster_layer(
            name='earthquake',
            extension='.tif',
            include_keywords=True,
            source_directory=standard_data_path('hazard')
        )
        message = ('%s raster layer should not be polygonal' % layer)
        self.assertFalse(is_polygon_layer(layer), message)
开发者ID:akbargumbira,项目名称:inasafe,代码行数:25,代码来源:test_gis.py


示例16: test_transparency_of_minimum_value

    def test_transparency_of_minimum_value(self):
        """Test that transparency of minimum value works when set to 100%
        """
        # This dataset has all cells with value 1.3
        data_path = standard_data_path('other', 'issue126.tif')
        layer, _ = load_layer(data_path)

        # Note the float quantity values below
        style_info = {
            'style_classes': [
                {'colour': '#FFFFFF', 'transparency': 100, 'quantity': 0.0},
                {'colour': '#38A800', 'quantity': 0.038362596547925065,
                 'transparency': 0, 'label': u'Rendah [0 orang/sel]'},
                {'colour': '#79C900', 'transparency': 0,
                 'quantity': 0.07672519309585013},
                {'colour': '#CEED00', 'transparency': 0,
                 'quantity': 0.1150877896437752},
                {'colour': '#FFCC00', 'quantity': 0.15345038619170026,
                 'transparency': 0, 'label': u'Sedang [0 orang/sel]'},
                {'colour': '#FF6600', 'transparency': 0,
                 'quantity': 0.19181298273962533},
                {'colour': '#FF0000', 'transparency': 0,
                 'quantity': 0.23017557928755039},
                {'colour': '#7A0000', 'quantity': 0.26853817583547546,
                 'transparency': 0, 'label': u'Tinggi [0 orang/sel]'}]}

        try:
            setRasterStyle(layer, style_info)
        except Exception, e:
            message = '\nCould not create raster style'
            e.args = (e.args[0] + message,)
            raise
开发者ID:easmetz,项目名称:inasafe,代码行数:32,代码来源:test_styling.py


示例17: test_retrieve_exposure_classes_lists

    def test_retrieve_exposure_classes_lists(self):
        """Test retrieve_exposure_classes_lists method.

        .. versionadded:: 4.0
        """
        layer_paths = self.layer_paths_list
        expected_classes_lists = [
            None,
            None,
            None,
            None,
            generic_structure_classes['classes'],
            generic_structure_classes['classes'],
            None,
            generic_road_classes['classes']
        ]

        for layer_path, expected_classes in zip(
                layer_paths, expected_classes_lists):
            path = standard_data_path(*layer_path)
            layer, _ = load_layer(path)
            actual_classes = retrieve_exposure_classes_lists(layer)
            try:
                self.assertEqual(
                    expected_classes, actual_classes)
            except Exception as e:
                LOGGER.error('Layer path: {path}'.format(
                    path=path))
                LOGGER.error('Expected {classes}'.format(
                    classes=expected_classes))
                LOGGER.error('Actual {classes}'.format(
                    classes=actual_classes))
                raise e
开发者ID:timlinux,项目名称:inasafe,代码行数:33,代码来源:test_util.py


示例18: test_polygonize

    def test_polygonize(self):
        """Test if we can polygonize a raster using GDAL."""

        raster_path = standard_data_path(
            'hazard', 'classified_flood_20_20.asc')
        driver = ogr.GetDriverByName('ESRI Shapefile')
        expected_field_name = 'my_field'

        shapefile = polygonize(raster_path, 1, expected_field_name)
        data_source = driver.Open(shapefile, 0)
        layer = data_source.GetLayer()

        layer_definition = layer.GetLayerDefn()
        field_name = layer_definition.GetFieldDefn(0).GetName()
        self.assertEqual(field_name, expected_field_name)

        self.assertEquals(layer.GetFeatureCount(), 400)

        layer.SetAttributeFilter('%s = 1' % expected_field_name)
        self.assertEquals(layer.GetFeatureCount(), 133)

        layer.SetAttributeFilter('%s = 2' % expected_field_name)
        self.assertEquals(layer.GetFeatureCount(), 134)

        layer.SetAttributeFilter('%s = 3' % expected_field_name)
        self.assertEquals(layer.GetFeatureCount(), 133)
开发者ID:easmetz,项目名称:inasafe,代码行数:26,代码来源:test_gdal_ogr_tools.py


示例19: test_polygonize_thresholds

    def test_polygonize_thresholds(self):
        """Test polygonize raster using gdal with some thresholds."""

        raster_path = standard_data_path('hazard', 'jakarta_flood_design.tif')

        inside_file_name, inside_layer_name, outside_file_name, \
            outside_layer_name = polygonize_thresholds(
                raster_path, 0.5)

        # Syntactic sugar to ignore unused vars.
        _ = inside_layer_name
        _ = outside_layer_name

        driver = ogr.GetDriverByName('ESRI Shapefile')

        data_source = driver.Open(inside_file_name, 0)
        layer = data_source.GetLayer()
        feature_count = layer.GetFeatureCount()
        # print 'inside %s' % (inside_file_name)
        self.assertEquals(feature_count, 3)

        data_source2 = driver.Open(outside_file_name, 0)
        layer2 = data_source2.GetLayer()
        feature_count2 = layer2.GetFeatureCount()
        # print 'outside %s' % (outside_file_name)
        self.assertEquals(feature_count2, 1)
开发者ID:easmetz,项目名称:inasafe,代码行数:26,代码来源:test_gdal_ogr_tools.py


示例20: test_print_impact_table

    def test_print_impact_table(self):
        """Test print impact table to pdf."""
        impact_layer_path = standard_data_path(
            'impact', 'population_affected_entire_area.shp')
        layer, _ = load_layer(impact_layer_path)
        # noinspection PyUnresolvedReferences,PyArgumentList
        QgsMapLayerRegistry.instance().addMapLayer(layer)
        # noinspection PyCallingNonCallable
        rect = QgsRectangle(106.8194, -6.2108, 106.8201, -6.1964)
        CANVAS.setExtent(rect)
        CANVAS.refresh()

        template = resources_path(
            'qgis-composer-templates', 'a4-portrait-blue.qpt')
        report = ImpactReport(IFACE, template, layer)
        report.template = template  # just to cover set template
        out_path = unique_filename(
            prefix='test_print_impact_table',
            suffix='.pdf',
            dir=temp_dir('test'))
        report.print_impact_table(out_path)

        # Check the file exists
        message = 'Rendered output does not exist: %s' % out_path
        self.assertTrue(os.path.exists(out_path), message)

        # Check the file is not corrupt
        message = 'The output file %s is corrupt' % out_path
        out_size = os.stat(out_path).st_size
        self.assertTrue(out_size > 0, message)
开发者ID:easmetz,项目名称:inasafe,代码行数:30,代码来源:test_impact_report.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utilities.test_data_path函数代码示例发布时间:2022-05-27
下一篇:
Python utilities.setup_scenario函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap