greenwich/raster.py
def raster(self, path, size, bandtype=gdal.GDT_Byte):
        """Returns a new Raster instance.

        gdal.Driver.Create() does not support all formats.

        Arguments:
        path -- file object or path as str
        size -- two or three-tuple of (xsize, ysize, bandcount)
        bandtype -- GDAL pixel data type
        """
        path = getattr(path, 'name', path)
        try:
            is_multiband = len(size) > 2
            nx, ny, nbands = size if is_multiband else size + (1,)
        except (TypeError, ValueError) as exc:
            exc.args = ('Size must be 2 or 3-item sequence',)
            raise
        if nx < 1 or ny < 1:
            raise ValueError('Invalid raster size %s' % (size,))
        # Do not write to a non-empty file.
        if not self._is_empty(path):
            raise IOError('%s already exists, open with Raster()' % path)
        ds = self.Create(path, nx, ny, nbands, bandtype)
        if not ds:
            raise ValueError(
                'Could not create %s using %s' % (path, str(self)))
        return Raster(ds)
def raster(self, path, size, bandtype=gdal.GDT_Byte):
        path = getattr(path, 'name', path)
        try:
            is_multiband = len(size) > 2
            nx, ny, nbands = size if is_multiband else size + (1,)
        except (TypeError, ValueError) as exc:
            exc.args = ('Size must be 2 or 3-item sequence',)
            raise
        if nx < 1 or ny < 1:
            raise ValueError('Invalid raster size %s' % (size,))
        # Do not write to a non-empty file.
        if not self._is_empty(path):
            raise IOError('%s already exists, open with Raster()' % path)
        ds = self.Create(path, nx, ny, nbands, bandtype)
        if not ds:
            raise ValueError(
                'Could not create %s using %s' % (path, str(self)))
        return Raster(ds)
def raster ( self , path , size , bandtype = gdal . GDT_Byte ) : path = getattr ( path , 'name' , path ) try : is_multiband = len ( size ) > 2 nx , ny , nbands = size if is_multiband else size + ( 1 , ) except ( TypeError , ValueError ) as exc : exc . args = ( 'Size must be 2 or 3-item sequence' , ) raise if nx < 1 or ny < 1 : raise ValueError ( 'Invalid raster size %s' % ( size , ) ) # Do not write to a non-empty file. if not self . _is_empty ( path ) : raise IOError ( '%s already exists, open with Raster()' % path ) ds = self . Create ( path , nx , ny , nbands , bandtype ) if not ds : raise ValueError ( 'Could not create %s using %s' % ( path , str ( self ) ) ) return Raster ( ds )
Returns a new Raster instance.

        gdal.Driver.Create() does not support all formats.

        Arguments:
        path -- file object or path as str
        size -- two or three-tuple of (xsize, ysize, bandcount)
        bandtype -- GDAL pixel data type
Returns a new Raster instance .