Search code examples
python-3.xaltairvega-lite

Some projections from Vega-Lite do not work in Altair


Based on the stack trace, I can see that Altair only accepts the following projections -

['albers', 'albersUsa', 'azimuthalEqualArea', 'azimuthalEquidistant', 'conicConformal', 'conicEqualArea', 'conicEquidistant', 'equalEarth', 'equirectangular', 'gnomonic', 'identity', 'mercator', 'naturalEarth1', 'orthographic', 'stereographic', 'transverseMercator']

However, I really wanted to have a polyhedral based projection, Cahill-Keyes specifically. After a bit of searching I found this page where I can see all the Vega-Lite projections - https://observablehq.com/@vega/vega-lite-cartographic-projections and it does have a few polyhedral projections.

However quite a lot of them do not seem to be supported in Altair. I am of the opinion that generally whatever is available in Vega-Lite can be done using Altair, so I am wondering why has Altair limited the number of projections?


Solution

  • Altair follows the Vega-Lite schema.

    Vega-Lite lists supported projections in the ProjectionType definition; according to this, the allowed projection types are the following:

       "ProjectionType": {
          "enum": [
            "albers",
            "albersUsa",
            "azimuthalEqualArea",
            "azimuthalEquidistant",
            "conicConformal",
            "conicEqualArea",
            "conicEquidistant",
            "equalEarth",
            "equirectangular",
            "gnomonic",
            "identity",
            "mercator",
            "naturalEarth1",
            "orthographic",
            "stereographic",
            "transverseMercator"
          ],
          "type": "string"
        },
    

    Altair will raise an error if you specify a projection that does not match one of these.