From https://github.com/Toblerity/Fiona/issues/572, I see that properties of type datetime.time are not supported for ESRI Shapefiles, but surely a str property named "time" is acceptable?
Fiona raises DriverSupportError: ESRI Shapefile does not support time fields for schemas that have a property named "time".
Running this code:
import fiona
schema = {
"geometry": "Point",
"properties": {
"time": "str", # type is str, should be okay
}
}
c = fiona.collection("time_bug.shp", "w", "ESRI Shapefile", schema)
Gives this result:
Traceback (most recent call last):
File "/vagrant/fiona_time_bug.py", line 13, in <module>
c = fiona.collection("time_bug.shp", "w", "ESRI Shapefile", schema)
File "/opt/DataPortal/lib/python3.6/site-packages/fiona/env.py", line 405, in wrapper
return f(*args, **kwargs)
File "/opt/DataPortal/lib/python3.6/site-packages/fiona/__init__.py", line 263, in open
**kwargs)
File "/opt/DataPortal/lib/python3.6/site-packages/fiona/collection.py", line 145, in __init__
self._check_schema_driver_support()
File "/opt/DataPortal/lib/python3.6/site-packages/fiona/collection.py", line 419, in _check_schema_driver_support
raise DriverSupportError("ESRI Shapefile does not support time fields")
fiona.errors.DriverSupportError: ESRI Shapefile does not support time fields
Linux-3.10.0-514.el7.x86_64-x86_64-with-centos-7.3.1611-Core
Python 3.6.5
Installed from PyPI via pip:
Fiona 1.8.3
GDAL 2.3.2
The source of the exception is collection.py:
def _check_schema_driver_support(self):
"""Check support for the schema against the driver
See GH#572 for discussion.
"""
gdal_version_major = get_gdal_version_num() // 1000000
for field in self._schema["properties"]:
field_type = field.split(":")[0]
if self._driver == "ESRI Shapefile":
if field_type == "datetime":
raise DriverSupportError("ESRI Shapefile does not support datetime fields")
elif field_type == "time":
raise DriverSupportError("ESRI Shapefile does not support time fields")
It looks like the problem is withfield_type = field.split(":")[0]. The intent of this seems to be to separate the property type from its format, but field is the property name, right?
@mdklatt yes, you're right. We'll fix this in the next release. Next week, I think.
I think this should be:
for field in self._schema["properties"].values():
Resolved by #695.
I'm using the 1.8.13 version of Fiona installed from pip and I get this error when trying to create a shapefile. Can anyone please clarify if this issue is fixed in the latest release?
I can confirm that this is fixed for v1.8.13.post1.