vega-lite - 如何使用 vega-lite 放大 map ?

标签 vega-lite

我正在使用 vega-lite 将一些数据渲染到 map 上。目前,我有这个架构,它呈现附加的图像:

{
  "title": "What's the nearest city to you?",
  "data": {
    "values": "...",
    "format": {
      "type": "csv"
    }
  },
  "encoding": {},
  "projection": {
    "type": "mercator"
  },
  "layer": [
    {
      "data": {
        "values": "...",
        "format": {
          "type": "topojson",
          "feature": "world-borders"
        }
      },
      "mark": {
        "type": "geoshape",
        "fill": "lightgrey",
        "stroke": "darkgrey"
      },
      "width": 800,
      "height": 600
    },
    {
      "mark": {
        "type": "circle",
        "size": 50
      },
      "encoding": {
        "latitude": {
          "field": "latitude",
          "type": "quantitative"
        },
        "longitude": {
          "field": "longitude",
          "type": "quantitative"
        },
        "color": {
          "field": "count",
          "type": "quantitative",
          "scale": {
            "range": [ "#f0f921", "#fcce25", "#fca636", "#f2844b", "#e16462", "#cc4778", "#b12a90", "#8f0da4", "#6a00a8", "#41049d", "#0d0887" ]
          }
        },
        "size": {
          "field": "count",
          "type": "quantitative"
        }
      }
    }
  ]
}

the rendered view of this schema

现在这看起来整体不错!我很高兴!但我真的很想能够提供放大到数据最密集区域的渲染图像,特别是欧洲和美国大陆。我已经尝试了 vega 和 vega-lite 文档中指定的所有我能想到的方法,但都无济于事(我尝试的所有属性都很奇怪——比如以单个像素渲染所有圆圈或只是裁剪 map 。)

我真正想要的只是一种表达“向我展示 lat°long° 和 lat°long° 之间的数据 + map View ”的方式,但没有任何东西是为此目的而设计的。我该怎么做?

最佳答案

在当前的 Vega-Lite 版本中,平移和缩放不适用于地理投影。参见 https://github.com/vega/vega-lite/issues/3306了解更多详情。

关于vega-lite - 如何使用 vega-lite 放大 map ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53471426/

相关文章:

powerbi - 如何垂直对齐符号,以便它们与 y 轴标签对齐?

vega-lite - 如何在 vega-lite 中添加具有相同比例的 2 个系列的辅助 Y 轴?

Vegalite 日线图摆动

python - 移动浏览器 Vega-Lite 规范中的间隔选择

julia - 如何用 julia 语言用这个数据集制作一个好的图表?

vega-lite - 如何在Vega-lite轴标题中放置换行符?

python - 更改 Altair 折线图和面积图中的步长宽度

python - 如何强制 Altair 在特定轴上对热图(矩形)进行排序?

javascript - 如何在使用express.js时使用Vega在后端生成绘图

vega - 在 vega-lite 中格式化 Facet/Multi-View 标签