dtoolkit.geoaccessor.geoseries.geobuffer#
- dtoolkit.geoaccessor.geoseries.geobuffer(s: GeoSeries, distance: int | float | list[int | float] | ndarray | Series, /, **kwargs) GeoSeries[source]#
Creates geographic buffers for
GeoSeries.Reprojects input features into the UTM projection, buffers them, then reprojects back into the original geographic coordinates.
- Parameters:
- distanceint, float, list-like of int or float, the unit is meter.
The radius of the buffer. If numpy.ndarray or Series are used then it must have same length as the
s. ForGeoDataFrame.geobuffer, it would use the column name as the distance prior.
- Returns:
- GeoSeries
- Raises:
- ValueError
Requires the CRS of the inputting is WGS84 (epsg:4326).
- TypeError
If
distanceis not a number.- IndexError
If
distanceis a list-like but its length does not match the length ofs.If
distanceis a Series but its index does not match the index ofs.
- Warns:
- UserWarning
If the index of the inputting is not unique.
If the CRS of the inputting is not WGS84 (epsg:4326).
See also
Examples
>>> import dtoolkit.geoaccessor >>> import pandas as pd >>> df = ( ... pd.DataFrame( ... { ... "distance": [0, 10], ... "where": ["close to equator", "away from equator"], ... "x": [122, 100], ... "y": [55, 1], ... }, ... ) ... .from_xy( ... "x", ... "y", ... crs=4326, ... ) ... .drop(columns=["x", "y"]) ... ) >>> df distance where geometry 0 0 close to equator POINT (122 55) 1 10 away from equator POINT (100 1) >>> df.geobuffer(100) distance ... geometry 0 0 ... POLYGON ((122.00156 55.00001, 122.00156 54.999... 1 10 ... POLYGON ((100.0009 1, 100.00089 0.99991, 100.0... [2 rows x 3 columns]
For GeoDataFrame, it could use the column name as the distance to generate buffer.
>>> df.geobuffer("distance") distance ... geometry 0 0 ... POLYGON EMPTY 1 10 ... POLYGON ((100.00009 1, 100.00009 0.99999, 100.... [2 rows x 3 columns]