geopyspark.geotrellis.color module¶
This module contains functions needed to create color maps used in coloring tiles, PNGs, and GeoTiffs.
-
geopyspark.geotrellis.color.get_colors_from_colors(colors)¶ Returns a list of integer colors from a list of Color objects from the colortools package.
Parameters: colors ([colortools.Color]) – A list of color stops using colortools.Color Returns: [int]
-
geopyspark.geotrellis.color.get_colors_from_matplotlib(ramp_name, num_colors=256)¶ Returns a list of color breaks from the color ramps defined by Matplotlib.
Parameters: - ramp_name (str) – The name of a matplotlib color ramp. See the matplotlib documentation for a list of names and details on each color ramp.
- num_colors (int, optional) – The number of color breaks to derive from the named map.
Returns: [int]
-
class
geopyspark.geotrellis.color.ColorMap(cmap)¶ A class that wraps a GeoTrellis ColorMap class.
Parameters: cmap (py4j.java_gateway.JavaObject) – The JavaObjectthat represents the GeoTrellis ColorMap.-
cmap¶ py4j.java_gateway.JavaObject – The
JavaObjectthat represents the GeoTrellis ColorMap.
-
classmethod
build(breaks, colors=None, no_data_color=0, fallback=0, classification_strategy=<ClassificationStrategy.LESS_THAN_OR_EQUAL_TO: 'LessThanOrEqualTo'>)¶ Given breaks and colors, build a
ColorMapobject.Parameters: - breaks (dict or list or
np.ndarrayorHistogram) – If adictthen a mapping from tile values to colors, the latter represented as integers e.g., 0xff000080 is red at half opacity. If alistthen tile values that specify breaks in the color mapping. If aHistogramthen a histogram from which breaks can be derived. - colors (str or list, optional) – If a
strthen the name of a matplotlib color ramp. If alistthen either a list of colortoolsColorobjects or a list of integers containing packed RGBA values. IfNone, then theColorMapwill be created from thebreaksgiven. - no_data_color (int, optional) – A color to replace NODATA values with
- fallback (int, optional) – A color to replace cells that have no value in the mapping
- classification_strategy (str or
ClassificationStrategy, optional) – A string giving the strategy for converting tile values to colors. e.g., ifClassificationStrategy.LESS_THAN_OR_EQUAL_TOis specified, and the break map is {3: 0xff0000ff, 4: 0x00ff00ff}, then values up to 3 map to red, values from above 3 and up to and including 4 become green, and values over 4 become the fallback color.
Returns: - breaks (dict or list or
-
classmethod
from_break_map(break_map, no_data_color=0, fallback=0, classification_strategy=<ClassificationStrategy.LESS_THAN_OR_EQUAL_TO: 'LessThanOrEqualTo'>)¶ Converts a dictionary mapping from tile values to colors to a ColorMap.
Parameters: - break_map (dict) – A mapping from tile values to colors, the latter represented as integers e.g., 0xff000080 is red at half opacity.
- no_data_color (int, optional) – A color to replace NODATA values with
- fallback (int, optional) – A color to replace cells that have no value in the mapping
- classification_strategy (str or
ClassificationStrategy, optional) – A string giving the strategy for converting tile values to colors. e.g., ifClassificationStrategy.LESS_THAN_OR_EQUAL_TOis specified, and the break map is {3: 0xff0000ff, 4: 0x00ff00ff}, then values up to 3 map to red, values from above 3 and up to and including 4 become green, and values over 4 become the fallback color.
Returns:
-
classmethod
from_colors(breaks, color_list, no_data_color=0, fallback=0, classification_strategy=<ClassificationStrategy.LESS_THAN_OR_EQUAL_TO: 'LessThanOrEqualTo'>)¶ Converts lists of values and colors to a
ColorMap.Parameters: - breaks (list) – The tile values that specify breaks in the color mapping.
- color_list ([int]) – The colors corresponding to the values in the breaks list, represented as integers—e.g., 0xff000080 is red at half opacity.
- no_data_color (int, optional) – A color to replace NODATA values with
- fallback (int, optional) – A color to replace cells that have no value in the mapping
- classification_strategy (str or
ClassificationStrategy, optional) – A string giving the strategy for converting tile values to colors. e.g., ifClassificationStrategy.LESS_THAN_OR_EQUAL_TOis specified, and the break map is {3: 0xff0000ff, 4: 0x00ff00ff}, then values up to 3 map to red, values from above 3 and up to and including 4 become green, and values over 4 become the fallback color.
Returns:
-
classmethod
from_histogram(histogram, color_list, no_data_color=0, fallback=0, classification_strategy=<ClassificationStrategy.LESS_THAN_OR_EQUAL_TO: 'LessThanOrEqualTo'>)¶ Converts a wrapped GeoTrellis histogram into a
ColorMap.Parameters: - histogram (
Histogram) – AHistograminstance; specifies breaks - color_list ([int]) – The colors corresponding to the values in the breaks list, represented as integers e.g., 0xff000080 is red at half opacity.
- no_data_color (int, optional) – A color to replace NODATA values with
- fallback (int, optional) – A color to replace cells that have no value in the mapping
- classification_strategy (str or
ClassificationStrategy, optional) – A string giving the strategy for converting tile values to colors. e.g., ifClassificationStrategy.LESS_THAN_OR_EQUAL_TOis specified, and the break map is {3: 0xff0000ff, 4: 0x00ff00ff}, then values up to 3 map to red, values from above 3 and up to and including 4 become green, and values over 4 become the fallback color.
Returns: - histogram (
-