1

将此代码复制到https://en.wikipedia.org/wiki/Special:GraphSandbox

手动设置地理变换的比例和平移参数以匹配图像的宽度和高度(见红叉)。我怎样才能使地理转换自动匹配整个图形大小(或者可能是一些信号值),而无需手动调整?

更新: 翻译参数应该设置为图像宽度和高度的一半。请参阅下面的答案,并且中心应该已设置为 [0,0]。对于等角投影,图形大小应为 2:1。

{
  "version": 2, "width": 800, "height": 400, "padding": 0,
  "data": [
    {
      "name": "data",
      "values": [
        {"lat":0, "lon":0},
        {"lat":90, "lon":-180},
        {"lat":-90, "lon":180}
      ]
    }
  ],
  "marks": [
    {
      "type": "image",
      "properties": {
        "enter": {
          "url": {"value": "wikirawupload:{{filepath:Earthmap1000x500compac.jpg|190}}"},
          "width": {"signal": "width"},
          "height": {"signal": "height"}
        }
      }
    },
    {
      "name": "points",
      "type": "symbol",
      "from": {
        "data": "data",
        "transform": [{
            "type": "geo",
            "projection": "equirectangular",
            "scale": 127,
            "center": [0,0],
            "translate": [400,200],
            "lon": "lon",
            "lat": "lat"
        }]
      },
      "properties": {
        "enter": {
          "x": {"field": "layout_x"},
          "y": {"field": "layout_y"},
          "fill": {"value": "#ff0000"},
          "size": {"value": 500},
          "shape": {"value": "cross"}
        }
      }
    }
  ]
}
4

1 回答 1

0

找到答案(上面的示例已更新):"translate"应该设置为图像的中心。"center"另一方面,应设置为 [0,0] 。的投影需要设置"scale"equirectangularwidth/(2*PI)

于 2016-07-02T17:18:16.893 回答