Quick Start
This guide will walk you through the basic usage of Palettize. By the end, you’ll know how to preview colormaps, create exports, and use Palettize from Python.
Preview a Colormap
Section titled “Preview a Colormap”The show command renders a colormap preview directly in your terminal:
# Show a built-in presetpalettize show viridis
# Show a custom gradientpalettize show --colors "midnightblue,orange,gold"You can adjust the preview size:
palettize show viridis --width 80 --height 3Export a Colormap
Section titled “Export a Colormap”The create command exports colormaps to various file formats:
# Export viridis to GDAL format with a data domain of 0-255palettize create viridis --format gdal --output viridis.txt --domain 0,255Custom Colors
Section titled “Custom Colors”Instead of using a preset, you can define your own colors:
palettize create --colors "blue,white,red" --format gdal --output bwr.txt --domain 0,100Multiple Formats
Section titled “Multiple Formats”Export to multiple formats at once using the {name}, {format}, and {ext} placeholders:
palettize create viridis --format gdal,qgis,mapgl \ --output "output/{name}_{format}.{ext}" \ --domain 0,255 \ --steps 11This creates:
output/viridis_gdal.txtoutput/viridis_qgis.xmloutput/viridis_mapgl.json
List Available Resources
Section titled “List Available Resources”See what presets and exporters are available:
# List all colormap presetspalettize list presets
# List all export formatspalettize list exportersUsing from Python
Section titled “Using from Python”Palettize can also be used as a library:
from palettize import create_colormap, get_scaler_by_name
# Create a colormap from a presetcmap = create_colormap(preset="viridis", name="Viridis")
# Get a color at a specific position (0-1)hex_color = cmap.get_color(0.5) # Returns "#21918c"rgb = cmap.get_color(0.5, output_format="rgb_tuple") # Returns (33, 145, 140)
# Create from custom colorscmap2 = create_colormap( colors=["#0000ff", "white", "#ff0000"], name="BlueWhiteRed")
# Use a scaler to map data values to colorsscaler = get_scaler_by_name("linear", domain_min=0, domain_max=100)color_at_50 = cmap2.apply_scaler(50, scaler) # Color at the midpointNext Steps
Section titled “Next Steps”- Learn about all CLI commands
- Explore the Python API
- See all Export Formats
- Understand Color Interpolation