dtoolkit.geoaccessor.series.to_geoframe#
- dtoolkit.geoaccessor.series.to_geoframe(s: pd.Series, /, geometry: gpd.GeoSeries = None, crs: CRS | str | int = None, **kwargs) gpd.GeoDataFrame | pd.DataFrame[source]#
Transform an array of shapely scalars
Seriesto aGeoDataFrame.- Parameters:
- geometryGeoSeries, optional
It will be prior set as ‘geometry’ column on GeoDataFrame. If the input is a GeoSeries, its index will be ignored.
- crsCRS, str, int, optional
Coordinate Reference System of the geometry objects. Can be anything accepted by
from_user_input(), such as an authority string (eg “EPSG:4326” / 4326) or a WKT string.- **kwargs
See the documentation for
GeoDataFrameand for complete details on the keyword arguments.
- Returns:
- DataFrame or GeoDataFrame
GeoDataFrame if the data is an array of shapely scalars or
geometryis set.
Examples
>>> import dtoolkit.geoaccessor >>> import pandas as pd >>> s = pd.Series( ... pd.Series( ... [ ... "POINT (1 1)", ... "POINT (2 2)", ... "POINT (3 3)", ... ], ... name="wkt", ... ) ... .from_wkt(crs=4326) ... .geometry ... ) >>> s 0 POINT (1 1) 1 POINT (2 2) 2 POINT (3 3) Name: geometry, dtype: geometry >>> type(s) <class 'pandas.Series'> >>> gs = s.to_geoframe() >>> gs geometry 0 POINT (1 1) 1 POINT (2 2) 2 POINT (3 3) >>> type(gs) <class 'geopandas.geodataframe.GeoDataFrame'>