def pxbounds(self, geom, clip=False):
try:<EOL><INDENT>if isinstance(geom, dict):<EOL><INDENT>if '<STR_LIT>' in geom:<EOL><INDENT>geom = shape(geom['<STR_LIT>'])<EOL><DEDENT>else:<EOL><INDENT>geom = shape(geom)<EOL><DEDENT><DEDENT>elif isinstance(geom, BaseGeometry):<EOL><INDENT>geom = shape(geom)<EOL><DEDENT>else:<EOL><INDENT>geom = wkt.loads(geom)<EOL><DEDENT><DEDENT>except:<EOL><INDENT>raise TypeError ("<STR_LIT>")<EOL><DEDENT>if geom.disjoint(shape(self)):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>(xmin, ymin, xmax, ymax) = ops.transform(self.__geo_transform__.rev, geom).bounds<EOL>_nbands, ysize, xsize = self.shape<EOL>if clip:<EOL><INDENT>xmin = max(xmin, <NUM_LIT:0>)<EOL>ymin = max(ymin, <NUM_LIT:0>)<EOL>xmax = min(xmax, xsize)<EOL>ymax = min(ymax, ysize)<EOL><DEDENT>return (xmin, ymin, xmax, ymax)<EOL>
Returns the bounds of a geometry object in pixel coordinates

        Args:
            geom: Shapely geometry object or GeoJSON as Python dictionary or WKT string
            clip (bool): Clip the bounds to the min/max extent of the image

        Returns:
            list: bounds in pixels [min x, min y, max x, max y] clipped to image bounds