How to use the fiona.errors.FionaValueError 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_collection.py View on Github external
def test_closed_session_next(gdalenv, path_coutwildrnp_shp):
    """Confirm fix for  issue #687"""
    src = fiona.open(path_coutwildrnp_shp)
    itr = iter(src)
    list(itr)
    src.close()
    with pytest.raises(FionaValueError):
        next(itr)
github Toblerity / Fiona / tests / test_read_drivers.py View on Github external
def test_read_fail(path_coutwildrnp_shp):
    with pytest.raises(FionaValueError):
        fiona.open(path_coutwildrnp_shp, driver='GeoJSON')
    with pytest.raises(FionaValueError):
        fiona.open(path_coutwildrnp_shp, enabled_drivers=['GeoJSON'])
github Toblerity / Fiona / tests / test_read_drivers.py View on Github external
def test_read_fail(path_coutwildrnp_shp):
    with pytest.raises(FionaValueError):
        fiona.open(path_coutwildrnp_shp, driver='GeoJSON')
    with pytest.raises(FionaValueError):
        fiona.open(path_coutwildrnp_shp, enabled_drivers=['GeoJSON'])
github Toblerity / Fiona / tests / test_bytescollection.py View on Github external
def test_grenada_bytes_geojson(bytes_grenada_geojson):
    """Read grenada.geojson as BytesCollection.

    grenada.geojson is an example of geojson that GDAL's GeoJSON
    driver will fail to read successfully unless the file's extension
    reflects its json'ness.
    """
    # We expect an exception if the GeoJSON driver isn't specified.
    with pytest.raises(fiona.errors.FionaValueError):
        with fiona.BytesCollection(bytes_grenada_geojson) as col:
            pass

    # If told what driver to use, we should be good.
    with fiona.BytesCollection(bytes_grenada_geojson, driver='GeoJSON') as col:
        assert len(col) == 1
github ungarj / mapchete / mapchete / io / vector.py View on Github external
    tries=3, logger=logger, exceptions=(DriverError, FionaError, FionaValueError), delay=1
)
def _get_reprojected_features(
    input_file=None, dst_bounds=None, dst_crs=None, validity_check=False
):
    logger.debug("reading %s", input_file)
    try:
        with fiona.open(input_file, 'r') as src:
            src_crs = CRS(src.crs)
            # reproject tile bounding box to source file CRS for filter
            if src_crs == dst_crs:
                dst_bbox = box(*dst_bounds)
            else:
                dst_bbox = reproject_geometry(
                    box(*dst_bounds),
                    src_crs=dst_crs,
                    dst_crs=src_crs,
github Toblerity / Fiona / fiona / errors.py View on Github external
# Errors.


class FionaError(Exception):
    """Base Fiona error"""


class FionaValueError(ValueError):
    """Fiona-specific value errors"""


class DriverError(FionaValueError):
    """Encapsulates unsupported driver and driver mode errors."""


class SchemaError(FionaValueError):
    """When a schema mapping has no properties or no geometry."""


class CRSError(FionaValueError):
    """When a crs mapping has neither init or proj items."""


class DataIOError(IOError):
    """IO errors involving driver registration or availability."""


class DriverIOError(IOError):
github zackw / active-geolocator / maps / make_geog_baseline.py View on Github external
def shapefile(fname):
        if not fname:
            raise ArgumentTypeError("shapefile name cannot be empty")
        if fname[0] == '+':
            tag = '+'
            fname = fname[1:]
        else:
            tag = '?'
        try:
            return (tag, fiona.open(fname, 'r'))
        except FionaValueError as e:
            raise ArgumentTypeError(
                "%s: not a shapefile (%s)" % (fname, str(e)))
        except OSError as e:
            raise ArgumentTypeError(
                "%s: cannot open (%s)" % (fname, e.strerror))
github Toblerity / Fiona / fiona / errors.py View on Github external
# Errors.


class FionaError(Exception):
    """Base Fiona error"""


class FionaValueError(ValueError):
    """Fiona-specific value errors"""


class DriverError(FionaValueError):
    """Encapsulates unsupported driver and driver mode errors."""


class SchemaError(FionaValueError):
    """When a schema mapping has no properties or no geometry."""


class CRSError(FionaValueError):
    """When a crs mapping has neither init or proj items."""


class DataIOError(IOError):
    """IO errors involving driver registration or availability."""


class DriverIOError(IOError):
    """A format specific driver error."""


class DriverSupportError(DriverIOError):
github Toblerity / Fiona / fiona / errors.py View on Github external
"""Driver does not support schema"""


class DatasetDeleteError(IOError):
    """Failure to delete a dataset"""


class FieldNameEncodeError(UnicodeEncodeError):
    """Failure to encode a field name."""


class UnsupportedGeometryTypeError(KeyError):
    """When a OGR geometry type isn't supported by Fiona."""


class GeometryTypeValidationError(FionaValueError):
    """Tried to write a geometry type not specified in the schema"""


class TransactionError(RuntimeError):
    """Failure relating to GDAL transactions"""


class EnvError(FionaError):
    """Environment Errors"""


class GDALVersionError(FionaError):
    """Raised if the runtime version of GDAL does not meet the required
    version of GDAL.
    """
github zackw / active-geolocator / maps / make_region_pointsets.py View on Github external
def shapefile(fname):
        if not fname:
            raise ArgumentTypeError("shapefile name cannot be empty")
        try:
            return fiona.open(fname, 'r')
        except FionaValueError as e:
            raise ArgumentTypeError(
                "%s: not a shapefile (%s)" % (fname, str(e))) from e
        except OSError as e:
            raise ArgumentTypeError(
                "%s: cannot open (%s)" % (e.filename or fname,
                                          e.strerror)) from e