GeoJSONSeq append to file
See original GitHub issueExpected behavior and actual behavior.
Appending to a GeoJSON newline-delimited file is not currently supported.
I can’t find any other issues mentioning appending using GeoJSONSeq, and given the nature of the format, it seems like that should be possible. Where would a PR to enable that take place?
Steps to reproduce the problem.
import fiona
import geopandas as gpd
from geopandas.io.file import infer_schema
from shapely.geometry import Point
gdf = gpd.GeoDataFrame(geometry=[Point([0, 1])])
schema = infer_schema(gdf)
with fiona.open('test.geojson', "w", driver='GeoJSONSeq', schema=schema) as colxn:
colxn.writerecords(gdf.iterfeatures())
gdf = gpd.GeoDataFrame(geometry=[Point([2, 2])])
schema = infer_schema(gdf)
with fiona.open('test.geojson', "a", driver='GeoJSONSeq', schema=schema) as colxn:
colxn.writerecords(gdf.iterfeatures())
---------------------------------------------------------------------------
DriverError Traceback (most recent call last)
<ipython-input-26-01e338412202> in <module>
----> 1 with fiona.open('test.geojson', "a", driver='GeoJSONSeq', schema=schema) as colxn:
2
3 colxn.writerecords(gdf.iterfeatures())
4
~/local/anaconda3/envs/create-database/lib/python3.7/site-packages/fiona/env.py in wrapper(*args, **kwargs)
405 with Env.from_defaults(session=session):
406 log.debug("Credentialized: {!r}".format(getenv()))
--> 407 return f(*args, **kwargs)
408 return wrapper
409
~/local/anaconda3/envs/create-database/lib/python3.7/site-packages/fiona/__init__.py in open(fp, mode, driver, schema, crs, encoding, layer, vfs, enabled_drivers, crs_wkt, **kwargs)
252 if mode in ('a', 'r'):
253 c = Collection(path, mode, driver=driver, encoding=encoding,
--> 254 layer=layer, enabled_drivers=enabled_drivers, **kwargs)
255 elif mode == 'w':
256 if schema:
~/local/anaconda3/envs/create-database/lib/python3.7/site-packages/fiona/collection.py in __init__(self, path, mode, driver, schema, crs, encoding, layer, vsi, archive, enabled_drivers, crs_wkt, ignore_fields, ignore_geometry, **kwargs)
161
162 if self.session is not None:
--> 163 self.guard_driver_mode()
164
165 if self.mode in ("a", "w"):
~/local/anaconda3/envs/create-database/lib/python3.7/site-packages/fiona/collection.py in guard_driver_mode(self)
180 raise DriverError("unsupported driver: %r" % driver)
181 if self.mode not in supported_drivers[driver]:
--> 182 raise DriverError("unsupported mode: %r" % self.mode)
183
184 @property
DriverError: unsupported mode: 'a'
Operating system
For example: Mac OS X 10.15.1
Fiona and GDAL version and provenance
Fiona 1.8.11, from Conda Gdal 3.0.2, from Conda
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:14 (7 by maintainers)
Top Results From Across the Web
GeoJSONSeq: sequence of GeoJSON features - GDAL
The driver automatically reprojects geometries to WGS84 longitude, latitude, if the layer is created with another SRS. Appending to an existing file is ......
Read more >Append to geosjon file and save as .js file - Stack Overflow
I want to append "var data =" to geojson file and save it as .js but the file is created with "var data...
Read more >Command line-tool to convert geojson file to line-delimited ...
I'm loving the ndjson-cli tools for working with newline-delimited GeoJSON files. But I can't seem to find a tool that converts a standard ......
Read more >14.3. Exploring Data Formats and Fields - QGIS Documentation
Storing geometry information in delimited text files ... and click on Table ▻ Edit table, go to Indexes tab and click on Add...
Read more >Fiona 2.0dev documentation
Fiona reads and writes geographic data files and thereby helps Python programmers ... Missing GDAL support for TopoJSON, GeoJSONSeq, and ESRIJSON has been ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@kannes thank you. This not good: the raison d’être for GeoJSON sequences is to allow incremental parsing and appending. It’s not a write once format.
Yeah, agreed. I’m a little surprised it wasn’t supported by default when the functionality was added. I don’t know C/C++ or else I’d try to make a PR to GDAL. In any case, I’ll see what responses I get on the GDAL issue, linked above.