fiona.open('existing.json', 'w', driver='GeoJSON', ...) should clobber the existing file just like Python's builtin open() does. Instead, we get an opaque ValueError: null layer inside session.start(). See also #436 and #437.
Modification of tests/test_geojson.py's WriteTest.test_json() demonstrates the issue.
Any.
1.7.5 and earlier. All distributions.
Dataset and layer overwriting is complicated in GDAL. It's better in versions 2+ where it's easier to test driver capabilities.
As this bit me today here is a minimal example to reproduce this and the error message I got for googlability. Python 3 with pip packages GDAL==2.2.2 and Fiona==1.7.9.post1.
import fiona
from fiona.crs import from_epsg
from shapely.geometry import Point, mapping
schema = {
"geometry": "Point",
"properties": {"id": "int"}
}
feature = {
"geometry": mapping(Point(0,0)),
"properties": {"id": "0"}
}
for i in range(2):
with fiona.open("/tmp/test.geojson", "w",
driver="GeoJSON",
schema=schema,
crs=from_epsg(4326)) as sink:
sink.write(feature)
print(f"Write #{i+1} succeeded")
CPLE_NotSupportedError: GeoJSON driver doesn't support creating a layer on a read-only datasource
...
During handling of the above exception, another exception occurred:
...
DriverIOError: GeoJSON driver doesn't support creating a layer on a read-only datasource
I'm using fiona-git and still getting:
ERROR Fiona CPLE_NotSupported in b'The GeoJSON driver does not overwrite existing files.'
@eigenwillig Please can you provide some more information:
test_geojson.py::test_overwrite_json)?
Most helpful comment
As this bit me today here is a minimal example to reproduce this and the error message I got for googlability. Python 3 with pip packages GDAL==2.2.2 and Fiona==1.7.9.post1.