Replies: 3 comments 4 replies
-
Hi @nk9, fiona does not support naming geojsons, and more importantly, geojsons do not include a provision for layer names (see here). That said, I'd suggest you to work with geopackages instead. See the following example and a screenshot showing you how it looks when you open it with Qgis:
|
Beta Was this translation helpful? Give feedback.
-
@nk9 there are a bunch of GeoJSON driver options that allow name and description to be serialized at the feature collection level: https://gdal.org/drivers/vector/geojson.html#layer-creation-options. Unfortunately, none of them can help you because fiona has hard-wired GeoJSON collection names. See https://github.com/Toblerity/Fiona/blob/master/fiona/collection.py#L179-L182. This was a decision made long ago before the enhancements to the GeoJSON driver and is something that can be changed in the upcoming version 1.10. |
Beta Was this translation helpful? Give feedback.
-
Hi @sgillies, nice, I didn't know about that. The times I save/export vector layers in Qgis (with supposedly gdal in the back) to geojson, the layer name option is not enabled. @nk9 It won't be using Fiona, but you could use for instance the geojson library (
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have code to write an array of features out to a file. This is working, except that I want the generated GeoJSON file to have a specific top-level
name
attribute which is not derived from the file's name. Right now, thename
is not included when Fiona writes the file. However, when a file is edied with QGIS, it adds thename
if it's not present, defaulting to the file name without the.geojson
suffix.I've tried passing the string I want as the
layer
in theopen()
command, but that just results in "the GeoJSON format does not have layers". How do I configure this?Explanation: I'm using this field because it allows me to adjust the default layer name when the file is loaded into QGIS. I have a bunch of files, all of which are named "eds.geojson". They are identified by their location in a directory structure. But when loaded into QGIS, I want the added layer to be named "eds — my supplied layer name". And, as above: if I don't provide the name, QGIS will add it for me.
Beta Was this translation helpful? Give feedback.
All reactions