Gdalwrite.vect
Gdalwrite.vect is the part of GDAL, used to write Vector data and non-spatial data.
We test and support (options for) the following formats:
a layer is written complete
| A vector layer is written with all its storable [[attribute | attributes]], also when only one of them is requested: requesting a single attribute of a gdalwrite.vect Container calculates the other columns of the same layer and its Geometry, and writes them along, so the file is complete whichever column triggered the write. An attribute that fails to calculate takes no part in the write and gets no field, rather than blocking the file. |
A written attribute may refer to another written attribute of the same layer: the other columns are brought into play when the layer is actually written, not when a column comes under [[interest]].
A written column carries the engine’s canonical spelling of its Attribute name, which for a name that case-folds onto one of the engine’s own names (value, attr, unit, item, param, nrofrows, a Value type) is lower case: an attribute configured as Value produces a column named value. See case sensitivity for the rule and for what it means for consumers that read a column by its exact name.
the geometry column may have any name
The column that carries a layer’s Geometry is recognized by its Composition, polygon, arc, a point or multipoint, and not by its name. A geometry under another name, say region (polygon), gives its layer that geometry type and its features their shape. A column with composition multipoint is written as a MultiPoint per feature.
A geometry is not a field: the driver writes it as coordinates, so the field types of the driver say nothing about it, and a shapefile stores those coordinates as doubles whichever point Value type the model uses.
A geometry Attribute with its own .shp StorageName next to a .dbf on the Domain unit is not a gdalwrite.vect configuration unless you say so: it needs StorageType = "shp", the ESRI Shapefile storage manager, which writes the one attribute it is configured on and leaves the .dbf to the domain unit. Writing it with gdalwrite.vect instead makes GDAL create a whole layer, .dbf included, on top of the .dbf that the domain unit writes.
polygon rings are closed on write
Every ring of a Polygon is written closed: where the value does not repeat a ring’s first point at the end, gdalwrite.vect appends it before handing the ring to GDAL. Closure is what the ESRI Shapefile specification and OGC simple features require, and GDAL does not add the point itself.
a layer is written in one transaction
A layer is written in one transaction where the driver has them, such as GeoPackage, PostGIS and SQLite: when writing fails, none of the layer is kept. A layer written to a .gdb (OpenFileGDB, which emulates a transaction by backing up the layer’s files) is backed up once, not once per Tile. A driver without transactions, such as ESRI Shapefile or CSV, writes every feature directly.
see also
- Gdal.vect
- gdalwrite.grid
- Tree item name - case folding of written column names
files written by older versions
A layer that a version before 20.17.0 wrote on the request of a single attribute has its other columns as <null> columns and features without Geometry; write it again. A version before 20.19.0 writes a column in the spelling of its configuration, so an attribute Value gives a column Value; see case sensitivity.
A version before 20.19.2 recognizes the geometry column of a layer only by the name geometry. Under another name, a layer written as a whole is created without a geometry field and without an error: its features have no shape, and for a shapefile only the .dbf appears next to the configured .shp; write such a file again. Version 20.19.1 refuses a layer with such a geometry column, and versions 20.19.0 and 20.19.1 refuse a geometry attribute that carries its own StorageName, with
GDAL Error: driver ESRI Shapefile does not support writing of values type fpoint
because these versions measure the column against the creation field types of the driver, and no OGR field type corresponds to fpoint, dpoint or spoint. On these versions, name the geometry column geometry, as the examples on this wiki do. A version before 20.23.1 does not take a multipoint column for a geometry, whatever its name, and refuses the write as if the column were a field of a type the driver cannot store.
A version before 20.19.2 writes each ring as it is held, so a single-ring polygon that the model left open produces a file that Gdal.vect refuses to read back, with Check Failed Error: ring->getY(0) == ring->getY(numPoints-1). See ESRI Shapefile for the message in full, for why only single-ring values can be affected, and for what to do with such a file.
A version before 20.23.1 commits a transaction per Tile, also when writing fails, so a failed export of such a version can leave part of a layer behind, which its next run then updates in place.
Versions 20.17.0 up to and including 20.19.0 raise the error “Cannot start ChangeInterest while doing ChangeInterest; check for recursive dependencies” when one written attribute of a layer refers to another written attribute of the same layer, for example:
container Export : StorageName = "='%LocalDataDir%/result.csv'", StorageType = "gdalwrite.vect"
{
unit<uint8> sel := select_with_org_rel(condition)
{
attribute<string> name := org_rel->name;
attribute<string> RekenstapNaam := name; // refers to a sibling column: error in 20.17.0 .. 20.19.0
}
}
On those versions, let both attributes refer to the source directly (RekenstapNaam := org_rel->name;) instead of to the sibling column.
since version
7.408