dtoolkit.geoaccessor.series.from_wkt#

dtoolkit.geoaccessor.series.from_wkt(s: pd.Series, /, crs: CRS | str | int = None) gpd.GeoDataFrame[source]#

Generate GeoDataFrame of geometries from Series.

A sugary syntax wraps geopandas.GeoSeries.from_wkt().

Parameters:
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.

Returns:
GeoDataFrame
Raises:
ValueError

If the name of Series is empty.

Notes

This method is the accessor of Series, not GeoSeries.

Examples

>>> import dtoolkit.geoaccessor
>>> import pandas as pd
>>> s = pd.Series(
...     [
...         "POINT (1 1)",
...         "POINT (2 2)",
...         "POINT (3 3)",
...     ],
...     name='wkt',
... )
>>> s
0    POINT (1 1)
1    POINT (2 2)
2    POINT (3 3)
Name: wkt, dtype: object
>>> s.from_wkt(crs=4326)
           wkt                 geometry
0  POINT (1 1)  POINT (1.00000 1.00000)
1  POINT (2 2)  POINT (2.00000 2.00000)
2  POINT (3 3)  POINT (3.00000 3.00000)