Skip to content
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

Not possible to independently resolve latitude / longitude in concatenated geoshape chart with same projection #9321

Open
1 task done
kgoodrick-uu opened this issue Apr 25, 2024 · 2 comments
Labels

Comments

@kgoodrick-uu
Copy link

Bug Description

When concatenating two geoshape charts it is not possible to independently resolve the latitude and longitude when the same projection is used. As an example, consider a chart showing two US states side by side.

If we plot them separately, we get results exactly as we would expect, with the chart automatically adjusting the extent to the size of the data.

State A:
Open the Chart in the Vega Editor

{
  "config": {"view": {"continuousWidth": 300, "continuousHeight": 300}},
  "hconcat": [
    {
      "mark": {"type": "geoshape"},
      "transform": [{"filter": "(datum.id === 49)"}],
      "projection": {"type": "albersUsa"}
    }
  ],
  "data": {
    "url": "https://cdn.jsdelivr.net/npm/vega-datasets@v1.29.0/data/us-10m.json",
    "format": {"feature": "states", "type": "topojson"}
  },
  "$schema": "https://vega.github.io/schema/vega-lite/v5.17.0.json"
}

State B:
Open the Chart in the Vega Editor

{
  "config": {"view": {"continuousWidth": 300, "continuousHeight": 300}},
  "hconcat": [
    {
      "mark": {"type": "geoshape"},
      "transform": [{"filter": "(datum.id === 20)"}],
      "projection": {"type": "albersUsa"}
    }
  ],
  "data": {
    "url": "https://cdn.jsdelivr.net/npm/vega-datasets@v1.29.0/data/us-10m.json",
    "format": {"feature": "states", "type": "topojson"}
  },
  "$schema": "https://vega.github.io/schema/vega-lite/v5.17.0.json"
}

However, if we concatenate them the extent in each changes as if it were showing both states. I have attempted to set all of the resolve settings to independent, but none of them had any affect.

Open the Chart in the Vega Editor

{
  "config": {"view": {"continuousWidth": 300, "continuousHeight": 300}},
  "hconcat": [
    {
      "mark": {"type": "geoshape"},
      "transform": [{"filter": "(datum.id === 49)"}],
      "projection": {"type": "albersUsa"}
    },
    {
      "mark": {"type": "geoshape"},
      "transform": [{"filter": "(datum.id === 20)"}],
      "projection": {"type": "albersUsa"}
    }
  ],
  "data": {
    "url": "https://cdn.jsdelivr.net/npm/vega-datasets@v1.29.0/data/us-10m.json",
    "format": {"feature": "states", "type": "topojson"}
  },
  "$schema": "https://vega.github.io/schema/vega-lite/v5.17.0.json"
}

visualization (2)

If we additionally change the projection of each chart to something different, we get the expected behavior where each chart's extent is only for its data.

Open the Chart in the Vega Editor

{
  "config": {"view": {"continuousWidth": 300, "continuousHeight": 300}},
  "hconcat": [
    {
      "mark": {"type": "geoshape"},
      "transform": [{"filter": "(datum.id === 49)"}],
      "projection": {"type": "albersUsa"}
    },
    {
      "mark": {"type": "geoshape"},
      "transform": [{"filter": "(datum.id === 20)"}],
      "projection": {"type": "albers"}
    }
  ],
  "data": {
    "url": "https://cdn.jsdelivr.net/npm/vega-datasets@v1.29.0/data/us-10m.json",
    "format": {"feature": "states", "type": "topojson"}
  },
  "$schema": "https://vega.github.io/schema/vega-lite/v5.17.0.json"
}

visualization (3)

As users will generally want all maps in the same projection it would be desirable for each chart to independently resolve the extent without changing the projection.

I previously posted this on stack overflow as an Altair question and was asked to repost this here as an issue by @joelostblom.

Thanks!

Checklist

  • I checked for duplicate issues.
@kgoodrick-uu
Copy link
Author

I've identified a generic workaround that works for any projection and has minimal/no side effects. If one changes the precision of one of the projections it will treat them as separate projections and plot as desired

Open the Chart in the Vega Editor

{
  "config": {"view": {"continuousWidth": 300, "continuousHeight": 300}},
  "hconcat": [
    {
      "mark": {"type": "geoshape"},
      "transform": [{"filter": "(datum.id === 49)"}],
      "projection": {"type": "mercator", "precision": 0.707}
    },
    {
      "mark": {"type": "geoshape"},
      "transform": [{"filter": "(datum.id === 20)"}],
      "projection": {"type": "mercator"}
    }
  ],
  "data": {
    "url": "https://cdn.jsdelivr.net/npm/vega-datasets@v1.29.0/data/us-10m.json",
    "format": {"feature": "states", "type": "topojson"}
  },
  "$schema": "https://vega.github.io/schema/vega-lite/v5.17.0.json"
}

visualization (4)

I still think this is a bug, but this is a pretty good workaround until it's fixed.

@joelostblom
Copy link
Contributor

Thanks for filing this and for sharing your workaround @kgoodrick-uu !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants