From e7c6832acea591857ff283d595e5567541313931 Mon Sep 17 00:00:00 2001 From: Nat Wilson Date: Mon, 26 Jan 2015 11:21:12 -0800 Subject: [PATCH 1/3] reduce required GDAL to 1.10 not sure if this will cause runtime problems, but installing gdal can be a bear so it would be nice to use the version shipping in ubuntu 14.04 (1.10.1) --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 72267f7..283995b 100644 --- a/setup.py +++ b/setup.py @@ -51,7 +51,7 @@ setup(name="landsat", license="CCO", platforms="Posix; MacOS X; Windows", install_requires=[ - "GDAL==1.11.0", + "GDAL>=1.10.0", "elasticsearch==1.1.1", "gsutil==4.4", "requests==2.3.0", From 5b4b0a7c38a1581b41a1f06d6853f798471bb564 Mon Sep 17 00:00:00 2001 From: Nat Wilson Date: Wed, 13 Apr 2016 16:14:02 -0700 Subject: [PATCH 2/3] fix typo: Storge -> Storage --- landsat/downloader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/landsat/downloader.py b/landsat/downloader.py index 7cb4cef..c10f8cc 100644 --- a/landsat/downloader.py +++ b/landsat/downloader.py @@ -126,7 +126,7 @@ class Downloader(VerbosityMixin): self.remote_file_exists(url) - self.output('Source: Google Storge', normal=True, arrow=True) + self.output('Source: Google Storage', normal=True, arrow=True) return self.fetch(url, path) def amazon_s3(self, scene, bands): From 7feb87b51cd7cff8fbb5d0dc1ce3d0bbd3abc6d7 Mon Sep 17 00:00:00 2001 From: Nat Wilson Date: Fri, 22 Apr 2016 16:21:18 -0700 Subject: [PATCH 3/3] rewrite cloud/ice detection Performs bitwise comparisons along the BQA band. The old version checked for a particular list of values and was prone to overcounting. This version is based on the landsat documentation at http://landsat.usgs.gov/qualityband.php --- landsat/image.py | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/landsat/image.py b/landsat/image.py index 9e930e0..37659b7 100644 --- a/landsat/image.py +++ b/landsat/image.py @@ -288,24 +288,22 @@ class BaseProcess(VerbosityMixin): return numpy.percentile(color[numpy.logical_and(color > 0, color < 65535)], (low, high)) def _calculate_cloud_ice_perc(self): + """ Return the percentage of pixels that are either cloud or snow with + high confidence (> 67%). + """ self.output('Calculating cloud and snow coverage from QA band', normal=True, arrow=True) - a = rasterio.open(join(self.scene_path, self._get_full_filename('QA'))).read_band(1) - count = 0 - snow = [56320, 39936, 31744, 28590, 26656, 23552] - cloud = [61440, 59424, 57344, 53248, 28672, 36896, 36864, 24576] - - for item in cloud: - count += numpy.extract(a == item, a).size - - for item in snow: - count += numpy.extract(a == item, a).size * 2 - - perc = numpy.true_divide(count, a.size) * 100 + cloud_high_conf = int('1100000000000000', 2) + snow_high_conf = int('0000110000000000', 2) + fill_pixels = int('0000000000000001', 2) + cloud_mask = numpy.bitwise_and(a, cloud_high_conf) == cloud_high_conf + snow_mask = numpy.bitwise_and(a, snow_high_conf) == snow_high_conf + fill_mask = numpy.bitwise_and(a, fill_pixels) == fill_pixels + perc = numpy.true_divide(numpy.sum(cloud_mask | snow_mask), + a.size - numpy.sum(fill_mask)) * 100.0 self.output('cloud/snow coverage: %s' % round(perc, 2), indent=1, normal=True, color='green') - return perc def _filename(self, name=None, suffix=None, prefix=None):