Teradata Package for Python Function Reference | 17.10 - centroid - Teradata Package for Python

Teradata® Package for Python Function Reference

Product
Teradata Package for Python
Release Number
17.10
Published
April 2022
Language
English (United States)
Last Update
2022-08-19
Product Category
Teradata Vantage
teradataml.geospatial.geodataframe.GeoDataFrame.centroid
DESCRIPTION:
    Returns the mathematical centroid of an ST_Polygon or ST_MultiPolygon
    value.
 
PARAMETERS:
    None
 
SUPPORTED GEOMETRY TYPES:
    ST_Polygon or ST_MultiPolygon.
    Note:
        This method can be called on 3D geometries (those that include Z
        coordinates). However, the Z coordinate is dropped, and only x and y
        coordinates are returned.
 
RAISES:
    TypeError, ValueError, TeradataMlException
 
RETURNS:
    GeoDataFrame with result column containing ST_Point Geometry values
 
EXAMPLES:
    from teradataml import GeoDataFrame, load_example_data
    # Load example data.
    load_example_data("geodataframe", "sample_shapes")
    # Create a GeoDataFrame.
    gdf = GeoDataFrame("sample_shapes")
    gdf = gdf.select(["skey", "polygons", "linestrings"])[gdf.skey.isin([1001, 1002, 1003])]
    gdf
 
    # Example 1: Get the centroid of all Polygon geometries in column 'polygons'.
    # Let's check where the GeoDataFrame.geometry property points to.
    print(gdf.geometry.name)
    # Note: By default, GeoDataFrame.geometry property points to the first geometry column,
    #       in this case it is 'polygons'. Thus, no need to set it again.
    gdf.centroid