def get_centroid(polyg):
"""Return centroid of a polygon
Parameters
----------
polyg : :class:`numpy:numpy.ndarray`
of shape (num vertices, 2) or ogr.Geometry object
Returns
-------
out : x and y coordinate of the centroid
"""
if not type(polyg) == ogr.Geometry:
polyg = numpy_to_ogr(polyg, 'Polygon')
return polyg.Centroid().GetPoint()[0:2]
评论列表
文章目录