Skip to main content
2 of 6
rd
gene
  • 55.4k
  • 3
  • 113
  • 191

You don't need Fiona to write a GeoJSON file

features = [feat for feat in Fiona.open("a_shapefile.shp")
layer my_layer = {
     "type": "FeatureCollection",
      "features": features}
# save json file
import json #or GeoJSON
 with open('result.geojson', 'w') as outfile:
     json.dump(my_layer,outfile)

No CRS is explicitly defined inside the standard GeoJSON format but you can add the crs in my_layer. The coordinate reference system must be in a special format (OGC CRS URN, see What's up with the GeoJSON spec and CRS as a IRM?) not compatible with the Fiona .crs (PROJ4 format)

  layer my_layer = {
     "type": "FeatureCollection",
      "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::31370" } },
       "features": features}
gene
  • 55.4k
  • 3
  • 113
  • 191