def run(self, ips, imgs, para=None): prj = None if para['wkt'] != '': with open(para['wkt']) as f: prj = f.read() crs = gutil.makecrs(prj or para['crs']) table = gmt.build_index(imgs).to_crs(crs) box = gutil.shp2box(table, para['scale'] or (para['width'], para['height']), para['mar']) chans = ['Channel %s' % i for i in range(ips.get_nchannels())] chans = [chans.index(i) for i in para['chans']] order = {'nearest': 0, 'linear': 1}[para['order']] rst = gmt.match_multi(imgs, box, chans, step=para['step'], order=order) IPy.show_img([rst], ips.title + '-merge')
def run(self, tps, snap, data, para=None): prj = None if para['wkt'] != '': with open(para['wkt']) as f: prj = f.read() crs = gutil.makecrs(prj or para['crs']) table = data.to_crs(crs) box = gutil.shp2box(table, para['scale'] or (para['width'], para['height']), para['mar']) chans = list(data['channels'][0]) chans = [chans.index(i) for i in para['chans']] order = {'nearest': 0, 'linear': 1}[para['order']] rst = gmt.match_idx(data, box, chans, step=para['step'], order=order) IPy.show_img([rst], tps.title + '-merge')
def match_idx(idx, out, chan='all', step=10, order=1): if chan == 'all': chan = list(range(len(idx['channels'][0]))) if isinstance(chan, int): chan = [chan] if isinstance(out, tuple): shape, crs, mat = out else: shape, crs, mat = out.shape, out.crs, out.mat idx = idx.to_crs(gutil.makecrs(crs).to_proj4()) box = gutil.box2shp(shape, crs, mat)[0] for i in idx.index: if box.intersects(idx.loc[i]['geometry']): print(chan) raster = gio.read_raster(idx.loc[i]['path'], chan) if isinstance(out, tuple): out = gnp.frombox(*out, len(chan), raster.dtype) print('merge ...', idx.loc[i]['path'], end=' ') match_one(raster, out, chan, step, order) print('end') return out
def run(self, tps, snap, data, para=None): if not isinstance(data, gpd.GeoDataFrame): return IPy.alert('geo table needed!') IPy.show_log(tps.title, gutil.makecrs(data.crs).to_wkt())