code: def geoPolygonToPixelPolygonWKT(
      geom,
      inputRaster,
      targetSR,
      geomTransform,
      breakMultiPolygonGeo=True,
      pixPrecision=2,
  ):
      # Returns Pixel Coordinate List and GeoCoordinateList
  
      polygonPixBufferList = []
      polygonPixBufferWKTList = []
      if geom.GetGeometryName() == "POLYGON":
          polygonPix = ogr.Geometry(ogr.wkbPolygon)
          for ring in geom:
              # GetPoint returns a tuple not a Geometry
              ringPix = ogr.Geometry(ogr.wkbLinearRing)
  
              for pIdx in range(ring.GetPointCount()):
                  lon, lat, z = ring.GetPoint(pIdx)
                  xPix, yPix = latlon2pixel(
                      lat, lon, inputRaster, targetSR, geomTransform
                  )
  
                  xPix = round(xPix, pixPrecision)
                  yPix = round(yPix, pixPrecision)
                  ringPix.AddPoint(xPix, yPix)
  
              polygonPix.AddGeometry(ringPix)
          polygonPixBuffer = polygonPix.Buffer(0.0)
          polygonPixBufferList.append([polygonPixBuffer, geom])
  
      elif geom.GetGeometryName() == "MULTIPOLYGON":
          for poly in geom:
              polygonPix = ogr.Geometry(ogr.wkbPolygon)
              for ring in poly:
                  # GetPoint returns a tuple not a Geometry
                  ringPix = ogr.Geometry(ogr.wkbLinearRing)
  
                  for pIdx in range(ring.GetPointCount()):
                      lon, lat, z = ring.GetPoint(pIdx)
                      xPix, yPix = latlon2pixel(
                          lat, lon, inputRaster, targetSR, geomTransform
                      )
  
                      xPix = round(xPix, pixPrecision)
                      yPix = round(yPix, pixPrecision)
                      ringPix.AddPoint(xPix, yPix)
  
                  polygonPix.AddGeometry(ringPix)
              polygonPixBuffer = polygonPix.Buffer(0.0)
              if breakMultiPolygonGeo:
                  polygonPixBufferList.append([polygonPixBuffer, poly])
              else:
                  polygonPixBufferList.append([polygonPixBuffer, geom])
  
      for polygonTest in polygonPixBufferList:
          if polygonTest[0].GetGeometryName() == "POLYGON":
              polygonPixBufferWKTList.append(
                  [
                      polygonTest[0].ExportToWkt(),
                      polygonTest[1].ExportToWkt(),
                  ]
              )
          elif polygonTest[0].GetGeometryName() == "MULTIPOLYGON":
              for polygonTest2 in polygonTest[0]:
                  polygonPixBufferWKTList.append(
                      [
                          polygonTest2.ExportToWkt(),
                          polygonTest[1].ExportToWkt(),
                      ]
                  )
  
      return polygonPixBufferWKTList
  
imports: from osgeo import gdal, osr, ogr
  import numpy
label_desc: Use image node_id 2 for calling a global function with example usage: geoPolygonToPixelPolygonWKT(geom, inputRaster, targetSR, geomTransform, breakMultiPolygonGeo, pixPrecision) and returns: polygonPixBufferWKTList