elif ext == '.json': landsat[ext[1:]] = pathname pass if not landsat.has_key('json'): raise Exception('No JSON metadata file in ' + root) with open(landsat['json']) as metafile: metadata = json.load(metafile) mrgeo = MrGeo() # mrgeo.usedebug() mrgeo.start() bqa = mrgeo.ingest_image(landsat['bqa']) # bqa.export('/data/export/landsat-bqa.tif', singleFile=True) cloud_mask = bqa < 32768 # 0 where clouds, 1 where no clouds # cloud_mask.export('/data/export/landsat-clouds.tif', singleFile=True) red = cloud_mask.con(positiveRaster=mrgeo.ingest_image(landsat[4]), negativeConst=RasterMapOp.nan()) green = cloud_mask.con(positiveRaster=mrgeo.ingest_image(landsat[3]), negativeConst=RasterMapOp.nan()) blue = cloud_mask.con(positiveRaster=mrgeo.ingest_image(landsat[2]), negativeConst=RasterMapOp.nan()) # red = mrgeo.ingest_image(landsat[4]) # green = mrgeo.ingest_image(landsat[3]) # blue = mrgeo.ingest_image(landsat[2])
elif ext == ".json": landsat[ext[1:]] = pathname pass if not landsat.has_key("json"): raise Exception("No JSON metadata file in " + root) with open(landsat["json"]) as metafile: metadata = json.load(metafile) mrgeo = MrGeo() # mrgeo.usedebug() mrgeo.start() bqa = mrgeo.ingest_image(landsat["bqa"]) # bqa.export('/data/export/landsat-bqa.tif', singleFile=True) cloud_mask = bqa < 32768 # 0 where clouds, 1 where no clouds # cloud_mask.export('/data/export/landsat-clouds.tif', singleFile=True) red = cloud_mask.con(positiveRaster=mrgeo.ingest_image(landsat[4]), negativeConst=RasterMapOp.nan()) green = cloud_mask.con(positiveRaster=mrgeo.ingest_image(landsat[3]), negativeConst=RasterMapOp.nan()) blue = cloud_mask.con(positiveRaster=mrgeo.ingest_image(landsat[2]), negativeConst=RasterMapOp.nan()) # red = mrgeo.ingest_image(landsat[4]) # green = mrgeo.ingest_image(landsat[3]) # blue = mrgeo.ingest_image(landsat[2]) red.save("landsat-dn-r") # red.export('/data/export/landsat-dn-r.tif', singleFile=True) # green.export('/data/export/landsat-dn-g.tif', singleFile=True)