Skip to content
Snippets Groups Projects
Commit 1330879d authored by (no author)'s avatar (no author)
Browse files

adding constants for the geotiff names and including the concept of 4 and 5 channel geotiffs

git-svn-id: https://svn.ssec.wisc.edu/repos/glance/trunk@226 8a9318a1-56ba-4d59-b755-99d26321be01
parent ec72cfc8
No related branches found
No related tags found
No related merge requests found
......@@ -988,19 +988,54 @@ class tiff (object):
_tiff = None
GRAY_NAME = "grayscale value"
RED_NAME = "red"
GREEN_NAME = "green"
BLUE_NAME = "blue"
IR_NAME = "infrared"
ALPHA_NAME = "alpha"
# if we are using meaningful names, we will translate between
# the band index numbers and these names (otherwise bands use generic names)
EXPECTED_BAND_NAME_KEY = {
1: ["grayscale value"],
3: ["red", "green", "blue"],
4: ["red", "green", "blue", "alpha"],
1: [GRAY_NAME],
2: [GRAY_NAME, ALPHA_NAME],
3: [RED_NAME, GREEN_NAME, BLUE_NAME],
4: [RED_NAME, GREEN_NAME, BLUE_NAME, ALPHA_NAME],
5: [RED_NAME, GREEN_NAME, BLUE_NAME, IR_NAME, ALPHA_NAME],
}
SPECIAL_NAMES_TO_IDX = {
"grayscale value": 1,
"red": 1,
"green": 2,
"blue": 3,
"alpha": 4,
# a reverse look up to help disambigurate what meaningful name goes with
# which number (one of these dictionaries will be selected based on the
# number of bands in the geotiff)
REV_INFO = {
1: {
GRAY_NAME: 1,
},
2: {
GRAY_NAME: 1,
ALPHA_NAME: 2,
},
3: {
RED_NAME: 1,
GREEN_NAME: 2,
BLUE_NAME: 3,
},
4: {
RED_NAME: 1,
GREEN_NAME: 2,
BLUE_NAME: 3,
ALPHA_NAME: 4,
},
5: {
RED_NAME: 1,
GREEN_NAME: 2,
BLUE_NAME: 3,
IR_NAME: 4,
ALPHA_NAME: 5,
},
}
def _get_generic_band_name (self, number) :
......@@ -1012,14 +1047,14 @@ class tiff (object):
"""get an index for the band from a name
name may be either a meaningful name from the list that shows
up in SPECIAL_NAMES_TO_IDX's keys or a generic name that was
up in the reverse index keys or a generic name that was
generated by _get_generic_band_name
"""
to_return = None
if name in self.SPECIAL_NAMES_TO_IDX.keys() :
to_return = self.SPECIAL_NAMES_TO_IDX[name]
if name in self.revIndex.keys() :
to_return = self.revIndex[name]
else :
to_return = int(name.split(' ')[-1])
......@@ -1036,6 +1071,7 @@ class tiff (object):
self._tiff = gdal.Open(filename)
self.niceNames = useMeaningfulNames
self.revIndex = self.REV_INFO[self._tiff.RasterCount]
def __call__(self):
"yield names of variables to be compared"
......@@ -1155,7 +1191,9 @@ class tiff (object):
return True
# people also name tiff files with one f...
tif = tiff
tif = tiff
# Nick has special tiff files with alpha...
tifa = tiff
def _search_xml(pathname):
xs = '.xml'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment