greenwich/raster.py
def get_offset(self, envelope):
        """Returns a 4-tuple pixel window (x_offset, y_offset, x_size, y_size).

        Arguments:
        envelope -- coordinate extent tuple or Envelope
        """
        if isinstance(envelope, collections.Sequence):
            envelope = Envelope(envelope)
        if not (self.envelope.contains(envelope) or
                self.envelope.intersects(envelope)):
            raise ValueError('Envelope does not intersect with this extent')
        coords = self.affine.transform((envelope.ul, envelope.lr))
        nxy = [(min(dest, size) - origin) or 1
               for size, origin, dest in zip(self.size, *coords)]
        return coords[0] + tuple(nxy)
def get_offset(self, envelope):
        """Returns a 4-tuple pixel window (x_offset, y_offset, x_size, y_size).

        Arguments:
        envelope -- coordinate extent tuple or Envelope
        """
        if isinstance(envelope, collections.Sequence):
            envelope = Envelope(envelope)
        if not (self.envelope.contains(envelope) or
                self.envelope.intersects(envelope)):
            raise ValueError('Envelope does not intersect with this extent')
        coords = self.affine.transform((envelope.ul, envelope.lr))
        nxy = [(min(dest, size) - origin) or 1
               for size, origin, dest in zip(self.size, *coords)]
        return coords[0] + tuple(nxy)
Returns a 4-tuple pixel window (x_offset, y_offset, x_size, y_size).

        Arguments:
        envelope -- coordinate extent tuple or Envelope