How to use the fiona.listlayers function in fiona

To help you get started, we’ve selected a few fiona examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Toblerity / Fiona / tests / test_listing.py View on Github external
def test_zip_path():
    assert fiona.listlayers('zip://tests/data/coutwildrnp.zip') == ['coutwildrnp']
github Toblerity / Fiona / tests / test_listing.py View on Github external
def test_directory_trailing_slash():
    assert fiona.listlayers('tests/data/') == ['coutwildrnp', 'gre']
github perrygeo / python-rasterstats / tests / test_io.py View on Github external
def test_layer_index():
    layer = fiona.listlayers(DATA).index('polygons')
    assert list(read_features(DATA, layer=layer)) == target_features
github Toblerity / Fiona / tests / test_listing.py View on Github external
def test_path_ioerror(self):
        self.assertRaises(IOError, fiona.listlayers, ("foobar"))
github Toblerity / Fiona / tests / test_listing.py View on Github external
def test_zip_path_arch():
    assert fiona.listlayers('/coutwildrnp.shp', vfs='zip://tests/data/coutwildrnp.zip') == ['coutwildrnp']
github Toblerity / Fiona / tests / test_remove.py View on Github external
create_sample_data(filename, "GPKG", layer="layer2")
    create_sample_data(filename, "GPKG", layer="layer3")
    create_sample_data(filename, "GPKG", layer="layer4")
    assert fiona.listlayers(filename) == ["layer1", "layer2", "layer3", "layer4"]

    # remove by index
    fiona.remove(filename, layer=2)
    assert fiona.listlayers(filename) == ["layer1", "layer2", "layer4"]

    # remove by name
    fiona.remove(filename, layer="layer2")
    assert fiona.listlayers(filename) == ["layer1", "layer4"]

    # remove by negative index
    fiona.remove(filename, layer=-1)
    assert fiona.listlayers(filename) == ["layer1"]

    # invalid layer name
    with pytest.raises(ValueError):
        fiona.remove(filename, layer="invalid_layer_name")

    # invalid layer index
    with pytest.raises(DatasetDeleteError):
        fiona.remove(filename, layer=999)
github Toblerity / Fiona / tests / test_listing.py View on Github external
def test_single_file():
    assert fiona.listlayers('tests/data/coutwildrnp.shp') == ['coutwildrnp']
github geowurster / gj2ascii / gj2ascii / cli.py View on Github external
]

    Returns
    -------
    list
        A list of tuples where the first element of each tuple is the datasource
        and the second is a list of layers to render.
    """

    output = []
    for ds_layers in value:
        _split = ds_layers.split(',')
        ds = _split[0]
        layers = _split[1:]
        if ds != '-' and (len(layers) is 0 or '%all' in layers):
            layers = fio.listlayers(ds)
        elif ds == '-':
            layers = [None]
        output.append((ds, layers))

    return output
github wq / itertable / itertable / gis / mixins.py View on Github external
def load(self):
        try:
            self.layers = fiona.listlayers(self.filename)
        except (ValueError, IOError):
            driver = guess_driver(self.filename)
            self.meta = {'driver': driver}
            self.empty_file = True