-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support categorical colour palettes #4
Comments
I have processed 2 datasets with categorical color palettes so far: For the permafrost and ground ice layer, the attribute to visualize has four different letters that each represent one type (% range) of extent of the permafrost coverage for the geometry (c = continuous, d = discontinuous, s = sporadic, i = isolated patches). To process the data in the visualization workflow, I created dummy number codes, one for each of the four letters, so 1-4. The full cleaning script is at assign numerical codeinput = "/home/jcohen/permafrost_ground_layer/data/permaice.shp"
perm = gpd.read_file(input)
# drop rows that have missing value for extent attribute
perm.dropna(subset = ['EXTENT'], inplace = True)
# add column that codes the categorical extent strings into numbers
# in order to do stats with the workflow and assign palette to this
# first, define the conditions and choices for new extent_code attribute
conditions = [
(perm['EXTENT'] == "C"),
(perm['EXTENT'] == "D"),
(perm['EXTENT'] == "S"),
(perm['EXTENT'] == "I")
]
choices = [4, 3, 2, 1]
# Use numpy.select() to assign extent_code based on the conditions and choices
perm['extent_code'] = np.select(conditions, choices) I made the palette 4 separate hex codes for 4 shades of blue. For the infrastructure layer, the categories already were in numbers, so I did not have to add a dummy code attribute to visualize. Since there were 7 types of infrastructure, I made the palette 7 separate hex codes. infrastructure config
For both datasets, I made the In order to communicate the string label of each color to the user on the PDG, we simply give the label for each category in the legend in the XML. See below the snippet of the XML for the infrastructure for example. assign labels in XML
|
In the future, we will need to process raster data that is categorical/qualitative in nature, e.g. the infrastructure layer. We need to be able to configure these types of colormaps and render web tiles that use them.
One option might be to start using the colormap functionality from the
rio-tiler
package. This package has other functionality that we will likely want to use when we build our workflow to accept raster data as input, instead of just vector data. (e.g. partial reads of GeoTIFFs, tiling overlapping GeoTIFFs, etc.)The text was updated successfully, but these errors were encountered: