geost.accessor.GeostFrame.to_header#
- GeostFrame.to_header(include_columns: str | Iterable[str] | None = None, coordinate_names: tuple[str, str] = None, crs: str | int | CRS = None) GeoDataFrame[source]#
Create a header GeoDataFrame from the DataFrame to be used as a header table for the creation of a
Collectionobject. The header contains one row per unique object in the DataFrame, identified by the “nr” column. The header can contain a geometry column with point geometries created from specified coordinate columns in the DataFrame. By default only the columns ‘nr’, ‘surface’, ‘x’, and ‘y’ or aliases (see POSSIBLE_COLUMN_NAMING incolumn_names) are included. Optional columns can be given to be included using the include_columns parameter.- Parameters:
include_columns (str | Iterable[str] | None, optional) – Columns to aditionally include in the header. The default is None, which means that only the default columns ‘nr’, ‘surface’, ‘x’ and ‘y’ or their aliases are included.
coordinate_names (tuple[str, str], optional) – Tuple specifying the names of the columns to be used as coordinates for the geometry column. The default is None, which means that it automatically tries to find the names of the x and y columns (see POSSIBLE_COLUMN_NAMING in
column_names). If not found, no geometry column will be created.crs (str | int | CRS, optional) – Coordinate reference system for the geometry column. The default is None, which means no CRS will be assigned to the resulting GeoDataFrame.
- Returns:
GeoDataFrame containing one row per unique object in the DataFrame, with optional geometry column and specified columns included or excluded.
- Return type:
gpd.GeoDataFrame
- Raises:
KeyError – Raised if the specified coordinate columns are not found in the DataFrame.
Examples
To create a header GeoDataFrame with only default columns from the DataFrame and no geometry column:
>>> header = data.gst.to_header()
To create a header GeoDataFrame with only default columns, two specified columns ‘column1’ and ‘column2’ from the DataFrame and no geometry column:
>>> header = data.gst.to_header(include_columns=["column1", "column2"])
To create a header GeoDataFrame with a geometry column created from alternative coordinate names and a specific CRS:
>>> header = data.gst.to_header( ... coordinate_names=("x_alternative", "y_alternative"), crs=28992, ... )