-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Hi there,
First of all, thanks for this great utility! When playing with it, I also came across the impressive ~7280 colorramps cpt-city archive, and am using some topo/topobath ramps to display terrain on maplibre via the recent hypso color-relief layer-type.
I've got a few questions relative to parsing the cpt-city CPT strings
- I want to parse the cpt string content into a
maplibre paint color-stopslike shown below. This is basically an array which starts withinterpolation, linear, elevationto declare that the interpolation should happen on the elevation attribute, with linear instead of discrete steps, and then the array declares the stop values and associated colors.
After fiddling withcpt2js parsePalette(cptString), I can retrieve all the color values array by callingpalette.colors()without any args
But I cannot find the equivalent to retrieve all stops values - tested withdomain, out, range, classes etc. This would be useful to convert the resulting cpt2js palette into a maplibre paint style array, and I have the intuition this is just me misinterpreting the options returned by the parsed object. According to the chromajs scale.domain doc, it should be domain, but in my case domain returns only the[min, max]range full range without any stops.
{
"type": "color-relief",
"source": "terrainSource",
"paint": {
"color-relief-opacity": 1,
"color-relief-color": [
"interpolate",
["linear"],
["elevation"],
0, "rgb(112, 209, 255)",
12.88581315, "rgb(113, 211, 247)",
// ...
],
}
}-
Some colorramps of cpt-city, especially for topobath & topography+bathymetry, have some stops duplicated, where eg
stop 0is often present twice - so stop values are not strictly increasing. Are these correctly parsed and fixed by cpt2js? Testing on the demo it does seem so which is already great. -
finally, would it make sense to include in the cpt2js library - which is made for parsing rather than data - the cpt-city database itself?
- As said above, there are 7280 colorramps in the whole cpt-city database, which is a pretty large dataset that can be retrieved from pkg Total, it amounts to a pretty large 4.22MB zipped archive, so probably out-of-scope for cpt2js.
- The copyright information associates next to the data companion
COPYING.xmlfiles which describe the type of license (via a pretty free-form field) and whether the ramp could be redistributed via a tag with attribute:<distribute><qgis distribute="yes/no" license="..."/></distribute>. - by parsing these, there seem to be 4891 colorramps with license
<qgis distribute="yes" .../>and 3806 colorramps with an open-licence (among CC, MIT, Apache, BSD, GPL), so still a pretty large database. - It might make more sense to only include the colorramps from cpt-city selection listed on homepage under section
Selections from the archivelike topo or topobath, which results in only a few 100kBs of data. These can be retrieved by looking into the views directory, which includes an xml representation of the different selections.