def gdal_to_dat(dest, bandid='Data'): """ GDAL to Data format Parameters ---------- dest - GDAL format GDAL format bandid - str band identity """ dat = Data() gtr = dest.GetGeoTransform() rtmp = dest.GetRasterBand(1) dat.data = rtmp.ReadAsArray() nval = rtmp.GetNoDataValue() dat.data = np.ma.masked_equal(dat.data, nval) dat.data.set_fill_value(nval) dat.data = np.ma.fix_invalid(dat.data) dat.nrofbands = dest.RasterCount dat.tlx = gtr[0] dat.tly = gtr[3] dat.dataid = bandid dat.nullvalue = nval dat.rows = dest.RasterYSize dat.cols = dest.RasterXSize dat.xdim = abs(gtr[1]) dat.ydim = abs(gtr[5]) dat.wkt = dest.GetProjection() dat.gtr = gtr return dat
def gdal_to_dat(dest, bandid='Data'): """ GDAL to Data format Parameters ---------- dest - GDAL format GDAL format bandid - str band identity """ dat = Data() gtr = dest.GetGeoTransform() rtmp = dest.GetRasterBand(1) dat.data = rtmp.ReadAsArray() nval = rtmp.GetNoDataValue() dat.data = np.ma.masked_equal(dat.data, nval) dat.data.set_fill_value(nval) dat.data = np.ma.fix_invalid(dat.data) dat.nrofbands = dest.RasterCount dat.tlx = gtr[0] dat.tly = gtr[3] dat.dataid = bandid dat.nullvalue = nval dat.rows = dest.RasterYSize dat.cols = dest.RasterXSize dat.xdim = abs(gtr[1]) dat.ydim = abs(gtr[5]) dat.wkt = dest.GetProjection() dat.gtr = gtr return dat
def init_grid(self, data): """ Initializes raster variables in the Data class Args: data (numpy masked array): masked array containing raster data.""" grid = Data() grid.data = data grid.cols = self.numx grid.rows = self.numy grid.xdim = self.dxy grid.ydim = self.dxy grid.tlx = self.xrange[0] grid.tly = self.yrange[1] return grid
def init_grid(self, data): """ Initializes raster variables in the Data class Args: data (numpy masked array): masked array containing raster data.""" grid = Data() grid.data = data grid.cols = self.numx grid.rows = self.numy grid.xdim = self.dxy grid.ydim = self.dxy grid.tlx = self.xrange[0] grid.tly = self.yrange[1] return grid