geopandas.GeoDataFrame.from_arrow#
- classmethod GeoDataFrame.from_arrow(table, geometry=None, to_pandas_kwargs=None)[source]#
Construct a GeoDataFrame from an Arrow table object based on GeoArrow extension types.
See https://geoarrow.org/ for details on the GeoArrow specification.
This functions accepts any tabular Arrow object implementing the Arrow PyCapsule Protocol (i.e. having an
__arrow_c_array__or__arrow_c_stream__method).Added in version 1.0.
- Parameters:
- tablepyarrow.Table or Arrow-compatible table
Any tabular object implementing the Arrow PyCapsule Protocol (i.e. has an
__arrow_c_array__or__arrow_c_stream__method). This table should have at least one column with a geoarrow geometry type.- geometrystr, default None
The name of the geometry column to set as the active geometry column. If None, the first geometry column found will be used.
- to_pandas_kwargsdict, optional
Arguments passed to the pa.Table.to_pandas method for non-geometry columns. This can be used to control the behavior of the conversion of the non-geometry columns to a pandas DataFrame. For example, you can use this to control the dtype conversion of the columns. By default, the to_pandas method is called with no additional arguments.
- Returns:
- GeoDataFrame
Examples
>>> import geoarrow.pyarrow as ga >>> import pyarrow as pa >>> table = pa.Table.from_arrays([ ... ga.as_geoarrow( ... [None, "POLYGON ((0 0, 1 1, 0 1, 0 0))", "LINESTRING (0 0, -1 1, 0 -1)"] ... ), ... pa.array([1, 2, 3]), ... pa.array(["a", "b", "c"]), ... ], names=["geometry", "id", "value"]) >>> gdf = geopandas.GeoDataFrame.from_arrow(table) >>> gdf geometry id value 0 None 1 a 1 POLYGON ((0 0, 1 1, 0 1, 0 0)) 2 b 2 LINESTRING (0 0, -1 1, 0 -1) 3 c