Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/rasterstats/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
from __future__ import division
import sys
import json
from json.decoder import JSONDecodeError
import math
import fiona
from fiona.errors import DriverError
import rasterio
import warnings
from rasterio.transform import guard_transform
Expand Down Expand Up @@ -88,14 +90,14 @@ def fiona_generator(obj):
yield feature

features_iter = fiona_generator(obj)
except (AssertionError, TypeError, IOError, OSError):
except (AssertionError, TypeError, IOError, OSError, DriverError):
try:
mapping = json.loads(obj)
if 'type' in mapping and mapping['type'] == 'FeatureCollection':
features_iter = mapping['features']
elif mapping['type'] in geom_types + ['Feature']:
features_iter = [parse_feature(mapping)]
except ValueError:
except (ValueError, JSONDecodeError):
# Single feature-like string
features_iter = [parse_feature(obj)]
elif isinstance(obj, Mapping):
Expand Down