5

You can set the default output-extension of a model in processing > options > general. The intermediate transactions in a model are processed in that default file format.

After installing QGIS, the default extension is set to 'shp'.

A well-known disadvantage of using shp is the restriction in attributenames (set to 10 characters).

When I set the default to eg. 'geojson' I can evade the naming-restriction. But I then get some other errors on processing geometries.

So I'm looking for an explanation of the advantages and disadvantages of the different output-extensions used in the graphical modeller.

1 Answer 1

5

I must admit I hadn't noticed that option before :)

I'm not sure whether the current version of QGIS uses it for intermediate files, or just output files - it may use memory layers now. In either case, the principle is the same.

enter image description here

As you say, geojson has an advantage over shapefile - there's no need to truncate ("launder") field names.

The reason you might be getting errors changing the result, is that the geojson driver doesn't allow in-place edits. You can read an existing geojson file, create a new one, but you can't edit an existing one.

The same goes for rasters; some file types can't be written, only read.

The following code was cribbed from the Python GDAL/OGR cookbook

from osgeo import ogr

ds = ogr.Open("/path/to/some.geojson",0)
layer = ds.GetLayer()
capabilities = [
    ogr.OLCRandomRead,
    ogr.OLCSequentialWrite,
    ogr.OLCRandomWrite,
    ogr.OLCFastSpatialFilter,
    ogr.OLCFastFeatureCount,
    ogr.OLCFastGetExtent,
    ogr.OLCCreateField,
    ogr.OLCDeleteField,
    ogr.OLCReorderFields,
    ogr.OLCAlterFieldDefn,
    ogr.OLCTransactions,
    ogr.OLCDeleteFeature,
    ogr.OLCFastSetNextByIndex,
    ogr.OLCStringsAsUTF8,
    ogr.OLCIgnoreFields
]

print("Layer Capabilities:")
for cap in capabilities:
    print("  %s = %s" % (cap, layer.TestCapability(cap)))

The output for one geojson file is

Layer Capabilities:
  RandomRead = True
  SequentialWrite = False
  RandomWrite = False
  FastSpatialFilter = False
  FastFeatureCount = True
  FastGetExtent = False
  CreateField = False
  DeleteField = False
  ReorderFields = False
  AlterFieldDefn = False
  Transactions = False
  DeleteFeature = False
  FastSetNextByIndex = True
  StringsAsUTF8 = True
  IgnoreFields = False

From that, you can see GeoJSON files don't allow editing, and don't have their own spatial indexes. This page describes these capabilities in more detail.

You don't need code for this if you have a layer; right-click on a layer, properties, metadata and scroll down to "capabilities for this layer".

It's also possible that some formats may only support some geometry types... there may be restrictions on 25D, Curves etc. The formats available may depend on the version of QGIS and/or GDAL/OGR installed.

Which format to use depends on your specific requirements. I suspect that shp, sqlite and gpkg are probably the most flexible if you want to do further processing.

3
  • it would be extremely useful to replace the option to change the output format of the vectors. thank you
    – pigreco
    Commented May 24, 2019 at 19:49
  • not available in 3.14 madeira? couldn't find it anywhere.
    – neogeomat
    Commented Oct 18, 2019 at 0:44
  • 1
    After changing the options to shp also, Split vector gives results in Geopackage in Qgis 3.14.1 PI
    – MapQuest
    Commented Sep 11, 2020 at 13:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.