Skip to content

palettize create

The create command exports colormaps to one or more file formats for use in GIS applications, web mapping, and data visualization.

Terminal window
palettize create [PRESET_NAME] [OPTIONS]

Pass --format to export, --save to store the colormap, or both. A run with neither exits as a usage error.

ArgumentDescription
PRESET_NAMEPreset name (e.g. viridis) or path to a saved colormap JSON file. Optional if --colors is provided.
OptionShortDefaultDescription
--colors-cList of input colors to create a colormap from.
--space-soklchColor space for interpolation.
--cut0,1Sub-segment of the colormap to use (e.g., 0.2,0.8).
--reverse-rReverse the colormap before exporting.
--nameName for the colormap, used in file naming and output.
--saveWrite the colormap to this JSON path. Works without --format.
OptionShortDefaultDescription
--format-fExport format identifiers. Use multiple times or comma-separate. Required unless you only --save.
--output-ostdoutOutput path pattern. Supports {name}, {format}, {ext} placeholders.
--steps-n7Number of color steps. Minimum: 2. Also sets num_colors when that option is unset.
--precisionDecimal places for data values. Read by gdal and mapgl.
OptionShortDefaultDescription
--domain-d0,1Data domain for scaling (e.g., 0,100 or -10,10).
--scalelinearScaling type: linear, power, sqrt, log, symlog.
--scale-exponentExponent for power scale. Required when --scale=power.
--scale-log-base10Log base for log or symlog scales.
--scale-symlog-linthreshLinear threshold for symlog scale. Required when --scale=symlog.

--scale moves colors for gdal, mapgl, and for qgis / sld when they emit a gradient or ramp. Discrete QGIS ramps (exact, approximate) and discrete SLD maps (intervals, values) keep the colormap’s own stops. Other formats either ignore the scaler or record the scale name for the application to apply. palettize formats marks which formats use the domain and the scaler.

OptionShortDescription
--option-OPass format-specific options as key=value or exporter:key=value. Use multiple times.
Terminal window
# Export viridis to GDAL format
palettize create viridis --format gdal --output viridis.txt
# Export with custom data domain
palettize create viridis -f gdal -o viridis.txt --domain 0,255
Terminal window
# Create a blue-white-red diverging colormap
palettize create --colors "blue,white,red" -f gdal -o bwr.txt --domain -100,100

Use the {name}, {format}, and {ext} placeholders in the output path:

Terminal window
palettize create viridis --format gdal,qgis,mapgl \
--output "output/{name}_{format}.{ext}" \
--domain 0,255 \
--steps 11

This creates:

  • output/viridis_gdal.txt
  • output/viridis_qgis.xml
  • output/viridis_mapgl.json
Terminal window
# Generate 256 discrete colors
palettize create viridis -f gdal -o viridis.txt --steps 256
# Generate only 5 colors
palettize create viridis -f hex -n 5
Terminal window
palettize create viridis -f gdal -o output.txt --domain 0,100 --scale linear
Terminal window
palettize create viridis -f gdal -o output.txt --domain 0,100 --scale sqrt
Terminal window
# Quadratic scaling (exponent=2)
palettize create viridis -f gdal -o output.txt --domain 0,100 --scale power --scale-exponent 2
Terminal window
# Log base 10
palettize create viridis -f gdal -o output.txt --domain 1,1000 --scale log
# Log base 2
palettize create viridis -f gdal -o output.txt --domain 1,1024 --scale log --scale-log-base 2
Terminal window
palettize create --colors "blue,white,red" -f gdal -o output.txt \
--domain -100,100 --scale symlog --scale-symlog-linthresh 1

Use -O or --option to pass options to specific exporters:

Terminal window
# Set Observable Plot scale type
palettize create RdBu -f observable -o plot.json \
--domain -5,10 -O type=diverging -O pivot=0
# Target a specific exporter
palettize create viridis -f gdal,qgis \
-O gdal:nodata_value=0 -O qgis:ramp_type=exact

Omit --output to print the result:

Terminal window
# Print hex colors
palettize create viridis -f hex -n 5

Output:

#440154
#3b528b
#21918d
#5cc863
#fde725
Terminal window
palettize -v create viridis -f gdal -o viridis.txt --domain 0,255

Output:

Exporting to gdal...
Wrote viridis.txt
Export complete.
Terminal window
palettize create viridis --cut 0.2,0.8 --reverse --save my-map.json

Run palettize formats for the live list, including each format’s options:

IdentifierDescription
gdalGDAL Color Relief Text
qgisQGIS Color Ramp XML
sldOGC SLD XML
titilerTiTiler Colormap URL Parameter
mapglMapLibre GL JS Expression
observableObservable Plot Scale
geeGoogle Earth Engine Snippet
cssCSS Custom Properties
svgSVG Gradient
gimpGIMP Palette
jsonJSON
hexPlaintext Hexadecimal
rgbaPlaintext RGBA
hslPlaintext HSL

See Export Formats for detailed documentation of each format.