Example #1
0
def run():
    mtime = {}
    needup = []
    region_tiles = glob.glob("region.*x*.png")
    # first pass get all tile st_mtime
    for fregion in region_tiles:
        XxY = fregion.split('.')[1]
        sregion = os.stat(fregion)
        mtime[XxY] = sregion.st_mtime
        fprecis = "display.%s.precis.png" % XxY
        if os.path.isfile(fprecis):
            sprecis = os.stat(fprecis)
            if sregion.st_mtime <= sprecis.st_mtime:
                continue
        needup.append(XxY)
    mtime_min = min(mtime.values())
    mtime_max = max(mtime.values())
    mtime_fac = 1. / (mtime_max - mtime_min)
    mtime_col = lambda mt: (mt - mtime_min) * mtime_fac
    for XxY in needup:
        img = load("region.%s.png" % XxY)
        alpha = img[:, :, 1]
        save("display.%s.precis.png" % XxY,
             (viridis(alpha) * 255).astype('uint8'))
        alpha.fill(mtime_col(mtime[XxY]) * 255)
        save("display.%s.mtime.png" % XxY,
             (viridis(alpha) * 255).astype('uint8'))
Example #2
0
def run():
    mtime = {}
    needup = []
    region_tiles = glob.glob("region.*x*.png")
    # first pass get all tile st_mtime
    for fregion in region_tiles:
        XxY = fregion.split('.')[1]
        sregion = os.stat(fregion)
        mtime[XxY] = sregion.st_mtime
        fprecis = "display.%s.precis.png"%XxY
        if os.path.isfile(fprecis):
            sprecis = os.stat(fprecis)
            if sregion.st_mtime <= sprecis.st_mtime:
                continue
        needup.append(XxY)
    mtime_min = min(mtime.values())
    mtime_max = max(mtime.values())
    mtime_fac = 1./(mtime_max - mtime_min)
    mtime_col = lambda mt: (mt - mtime_min) * mtime_fac
    for XxY in needup:
        img = load("region.%s.png"%XxY)
        alpha = img[:,:,1]
        save("display.%s.precis.png"%XxY, (viridis(alpha)*255).astype('uint8'))
        alpha.fill(mtime_col(mtime[XxY])*255)
        save("display.%s.mtime.png"%XxY, (viridis(alpha)*255).astype('uint8'))
Example #3
0
def convert(fin, fout, cmin, cmax, cmap="viridis"):
    geo = gdal2(fin)
    npt = geo.bands[geo.names["N_POINTS"]]
    img = geo.bands[geo.names["Z_MEAN"]]
    img = (img - cmin) * (1.0 / (cmax - cmin))
    img[img > 1] = 1
    img[img < 0] = 0
    cmap = getattr(cm, cmap)
    img = (cmap(img) * 255).astype("uint8")
    img[npt < 1] = 0
    save(fout, img)
Example #4
0
def convert(fin, fout, cmin, cmax, cmap='viridis'):
    iin = load(fin) # get band as a numpy.array
    img = iin[:,:,0]
    alp = iin[:,:,1]
    img = (img - cmin) * (1./(cmax - cmin))
    img[img > 1] = 1
    img[img < 0] = 0
    cmap = getattr(cm, cmap)
    img = (cmap(img)*255).astype('uint8')
    img[alp < 1] = 255
    save(fout, img)
Example #5
0
def convert(fin, fout, cmin, cmax, cmap=colormap, npt=None):
    geo = gdal2(fin)
    img = geo.bands
    if len(img.shape) > 2: # multi-layer
        npt = geo.bands[geo.names["N_POINTS"]]
        img = geo.bands[geo.names["Z_MEAN"]]
    img = (img - cmin) * (1./(cmax - cmin))
    img[img > 1] = 1
    img[img < 0] = 0
    img[npt < 1] = 0
    # in case of JPEG or WebP, set quality to 90%, else this option is ignored
    save(fout, (cmap(img)*255).astype('uint8'))
Example #6
0
def convert(fin, fout, cmin, cmax, cmap=colormap, npt=None):
    geo = gdal2(fin)
    img = geo.bands
    if len(img.shape) > 2:  # multi-layer
        npt = geo.bands[geo.names["N_POINTS"]]
        img = geo.bands[geo.names["Z_MEAN"]]
    img = (img - cmin) * (1. / (cmax - cmin))
    img[img > 1] = 1
    img[img < 0] = 0
    img[npt < 1] = 0
    # in case of JPEG or WebP, set quality to 90%, else this option is ignored
    save(fout, (cmap(img) * 255).astype('uint8'))