-
Notifications
You must be signed in to change notification settings - Fork 115
Open
Description
When attempting to use a shapefile and you only have the .shp (not .shx / .dbf) the error you get is ultimately tied to trying to read a GeoJSON.
Traceback (most recent call last):
File “/opt/anaconda3/envs/geodata38/lib/python3.8/site-packages/rasterstats/io.py”, line 109, in read_features
mapping = json.loads(obj)
File “/opt/anaconda3/envs/geodata38/lib/python3.8/json/__init__.py”, line 357, in loads
return _default_decoder.decode(s)
File “/opt/anaconda3/envs/geodata38/lib/python3.8/json/decoder.py”, line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File “/opt/anaconda3/envs/geodata38/lib/python3.8/json/decoder.py”, line 355, in raw_decode
raise JSONDecodeError(“Expecting value”, s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
...
File “/opt/anaconda3/envs/geodata38/lib/python3.8/site-packages/rasterstats/io.py”, line 116, in read_features
features_iter = [parse_feature(obj)]
File “/opt/anaconda3/envs/geodata38/lib/python3.8/site-packages/rasterstats/io.py”, line 83, in parse_feature
raise ValueError(“Can’t parse %s as a geojson Feature object” % obj)
ValueError: Can’t parse /path/to/my.shp as a geojson Feature object
This might fall into the realm of what Fiona should handle, but a relatively simple check when using a shapefile to make sure the .shp, .shx, and .dbf all exist would solve the issue.
Metadata
Metadata
Assignees
Labels
No labels