geofileops.append_to#

geofileops.append_to(src: Union[str, PathLike[Any]], dst: Union[str, PathLike[Any]], src_layer: Optional[str] = None, dst_layer: Optional[str] = None, src_crs: Optional[Union[int, str]] = None, dst_crs: Optional[Union[int, str]] = None, columns: Optional[Iterable[str]] = None, where: Optional[str] = None, sql_stmt: Optional[str] = None, sql_dialect: Optional[Literal['SQLITE', 'OGRSQL']] = None, reproject: bool = False, explodecollections: bool = False, force_output_geometrytype: Optional[Union[GeometryType, str]] = None, create_spatial_index: Optional[bool] = True, append_timeout_s: int = 600, transaction_size: int = 50000, preserve_fid: Optional[bool] = None, dst_dimensions: Optional[str] = None, options: dict = {})#

Append src file to the dst file.

If an sql_stmt is specified, the sqlite query can contain following placeholders that will be automatically replaced for you:

  • {geometrycolumn}: the column where the primary geometry is stored.

  • {columns_to_select_str}: if ‘columns’ is not None, those columns, otherwise all columns of the layer.

  • {input_layer}: the layer name of the input layer.

Example SQL statement with placeholders:

SELECT {geometrycolumn}
      {columns_to_select_str}
  FROM "{input_layer}" layer

The options parameter can be used to pass any type of options to GDAL in the following form:

{ “<option_type>.<option_name>”: <option_value> }

The option types can be any of the following:
  • LAYER_CREATION: layer creation option (lco)

  • DATASET_CREATION: dataset creation option (dsco)

  • INPUT_OPEN: input dataset open option (oo)

  • DESTINATION_OPEN: destination dataset open option (doo)

  • CONFIG: config option (config)

The options can be found in the GDAL vector driver documentation.

Parameters:
  • src (Union[str,) – source file path.

  • dst (Union[str,) – destination file path.

  • src_layer (str, optional) – source layer. Defaults to None.

  • dst_layer (str, optional) – destination layer. Defaults to None.

  • src_crs (str, optional) – an epsg int or anything supported by the OGRSpatialReference.SetFromUserInput() call, which includes an EPSG string (eg. “EPSG:4326”), a well known text (WKT) CRS definition,… Defaults to None.

  • dst_crs (str, optional) – an epsg int or anything supported by the OGRSpatialReference.SetFromUserInput() call, which includes an EPSG string (eg. “EPSG:4326”), a well known text (WKT) CRS definition,… Defaults to None.

  • columns (Iterable[str], optional) – The (non-geometry) columns to read will be returned in the order specified. If None, all standard columns are read. In addition to standard columns, it is also possible to specify “fid”, a unique index available in all input files. Note that the “fid” will be aliased eg. to “fid_1”. Defaults to None.

  • where (str, optional) – only append the rows from src that comply to the filter specified. Applied before explodecollections. Filter should be in sqlite SQL WHERE syntax and spatialite reference functions can be used. If where contains the {geometrycolumn} placeholder, it is filled out with the geometry column name of the src file. Defaults to None.

  • sql_stmt (str) – SQL statement to use. Only supported with “pyogrio” engine.

  • sql_dialect (str, optional) – SQL dialect used. Options are None, “SQLITE” or “OGRSQL”. If None, for data sources with explicit SQL support the statement is processed by the default SQL engine (e.g. for Geopackage and Spatialite this is “SQLITE”). For data sources without native SQL support (e.g. .shp), the “OGRSQL” dialect is the default. If the “SQLITE” dialect is specified, spatialite reference functions can also be used. Defaults to None.

  • reproject (bool, optional) – True to reproject while converting the file. Defaults to False.

  • explodecollections (bool), optional) – True to output only simple geometries. Defaults to False.

  • force_output_geometrytype (Union[GeometryType, str], optional) – Geometry type. to (try to) force the output to. Defaults to None.

  • create_spatial_index (bool, optional) – True to create a spatial index on the destination file/layer. If None, the default behaviour by gdal for that file type is respected. If the LAYER_CREATION.SPATIAL_INDEX parameter is specified in options, create_spatial_index is ignored. If the destination layer exists already, create_spatial_index is also ignored. Defaults to True.

  • append_timeout_s (int, optional) – timeout to use if the output file is being written to by another process already. Defaults to 600.

  • transaction_size (int, optional) – Transaction size. Defaults to 50000.

  • preserve_fid (bool, optional) – True to make an extra effort to preserve fid’s of the source layer to the destination layer. False not to do any effort. None to use the default behaviour of gdal, that already preserves in some cases. Some file formats don’t explicitly store the fid (e.g. shapefile), so they will never be able to preserve fids. Defaults to None.

  • dst_dimensions (str, optional) – Force the dimensions of the destination layer to the value specified. Valid values: “XY”, “XYZ”, “XYM” or “XYZM”. Defaults to None.

  • options (dict, optional) – options to pass to gdal.

Raises:
  • ValueError – an invalid parameter value was passed.

  • RuntimeError – timeout was reached while trying to append data to path.