DataArray.xvec.to_geodataframe(*, name=None, dim_order=None, geometry=None, long=True)#

Convert this array and its coordinates into a tidy geopandas.GeoDataFrame.

The GeoDataFrame is indexed by the Cartesian product of index coordinates (in the form of a pandas.MultiIndex) excluding geometry coordinates. Other coordinates are included as columns in the GeoDataFrame. For 1D and 2D DataArrays, see also to_geopandas() which doesn’t rely on a MultiIndex to build the GeoDataFrame.

Geometry coordinates are forcibly removed from the index and stored as columns.

If there is only a single geometry coordinate axis, it is set as active geometry of the GeoDataFrame. If there are multiple or none in coordinates, geometry must be passed to set an active geometry column.

nameHashable or None, optional

Name to give to this array (required if unnamed). Applies only if the object is DataArray, otherwise ignored.

dim_orderSequence of Hashable or None, optional

Hierarchical dimension order for the resulting dataframe. Array content is transposed to this order and then written out as flat vectors in contiguous order, so the last dimension in this list will be contiguous in the resulting DataFrame. This has a major influence on which operations are efficient on the resulting dataframe. If provided, must include all dimensions of this DataArray. By default, dimensions are sorted according to the DataArray dimensions order.

geometryHashable, optional

A key of a geometry coordinates to be used as an active geometry of the resulting GeoDataFrame.

longBool, optional (default True)

A form of the table. If True, creates a long form as DataArray.to_dataframe. If False, creates a wide form with MultiIndex columns (as if you would call .unstack()). A wide form supports objects with only a single dimension of geometries.

GeoDataFrame | DataFrame

GeoPandas GeoDataFrame with coordinates based on GeometryIndex set as an active geometry or pandas DataFrame with GeometryArrays

See also