(geom, origin, ndim)
Returns interpreted coordinate tuple for origin parameter.

    This is a helper function for other transform functions.

    The point of origin can be a keyword 'center' for the 2D bounding box
    center, 'centroid' for the geometry's 2D centroid, a Point object or a
    coordinate tuple (x0, y0, z0).
Returns interpreted coordinate tuple for origin parameter.
Returns interpreted coordinate tuple for origin parameter .
def interpret_origin(geom, origin, ndim):
    """Returns interpreted coordinate tuple for origin parameter.

    This is a helper function for other transform functions.

    The point of origin can be a keyword 'center' for the 2D bounding box
    center, 'centroid' for the geometry's 2D centroid, a Point object or a
    coordinate tuple (x0, y0, z0).
    """
    # get coordinate tuple from 'origin' from keyword or Point type
    if origin == 'center':
        # bounding box center
        minx, miny, maxx, maxy = geom.bounds
        origin = ((maxx + minx)/2.0, (maxy + miny)/2.0)
    elif origin == 'centroid':
        origin = geom.centroid.coords[0]
    elif isinstance(origin, str):
        raise ValueError("'origin' keyword %r is not recognized" % origin)
    elif hasattr(origin, 'type') and origin.type == 'Point':
        origin = origin.coords[0]

    # origin should now be tuple-like
    if len(origin) not in (2, 3):
        raise ValueError("Expected number of items in 'origin' to be "
                         "either 2 or 3")
    if ndim == 2:
        return origin[0:2]
    else:  # 3D coordinate
        if len(origin) == 2:
            return origin + (0.0,)
        else:
            return origin
def interpret_origin ( geom , origin , ndim ) : # get coordinate tuple from 'origin' from keyword or Point type if origin == 'center' : # bounding box center minx , miny , maxx , maxy = geom . bounds origin = ( ( maxx + minx ) / 2.0 , ( maxy + miny ) / 2.0 ) elif origin == 'centroid' : origin = geom . centroid . coords [ 0 ] elif isinstance ( origin , str ) : raise ValueError ( "'origin' keyword %r is not recognized" % origin ) elif hasattr ( origin , 'type' ) and origin . type == 'Point' : origin = origin . coords [ 0 ] # origin should now be tuple-like if len ( origin ) not in ( 2 , 3 ) : raise ValueError ( "Expected number of items in 'origin' to be " "either 2 or 3" ) if ndim == 2 : return origin [ 0 : 2 ] else : # 3D coordinate if len ( origin ) == 2 : return origin + ( 0.0 , ) else : return origin