code: 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(
              f"'origin' keyword {origin!r} is not recognized"
          )
      elif getattr(origin, "geom_type", None) == "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
  
file_path: shapely/shapely/affinity.py
imports: from math import cos, pi, sin, tan
  import numpy
  import shapely
label_desc: Use image node_id 2 for calling a global function with example usage: interpret_origin(geom, origin, ndim) and returns: origin, unknown, origin