我正在尝试使用 geoshape 标记在 Vega-Lite 中绘制澳大利亚的尖角部分。我的 GeoJSON 文件根据 geojson.io 有效并正确显示: [凯恩斯地区]
但是,Vega-Lite 无法生成类似此图像的任何图像,当通过 mapshaper.org 检查时,CRS 设置为 WGS-84 和 EPGS-4326。
代码描述如下,在 Vega 编辑器中
有什么想法吗?
我尝试过内联为TopoJSON,将CRS字段添加到GeoJSON,然后使用R中的
{sf}
将地图重新投影到另一个CRS,例如3587(正如一些帖子提到的Mapshaper反转轴)。我也尝试过 Vega 而不是 Vega-Lite,但没有成功。
作为一种解决方法,从每个纬度中删除符号 (-) 并选择恒等投影可以提供足够好的视觉效果,但似乎仍然缺少某些内容。
编辑添加:刚刚找到用于投影的
reflectY
属性,这样就无需删除符号了。它仍然感觉像是一种解决方法,所以希望有人能够看到真正的问题。
投影有很多选项可以让您的地图显示正确的方向。我在这里使用了比例和中心,但也有其他方法。
https://vega.github.io/vega/docs/projections/
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"description": "A choropleth map depicting U.S. unemployment rates by county in 2009.",
"width": 960,
"height": 500,
"autosize": "none",
"data": [
{
"name": "counties",
"values": {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[141.29457654244217, -16.394971044334035],
[142.39113112209878, -16.550994658371685],
[142.52950790799136, -17.174916330896544],
[142.20337079923343, -17.44324930166118],
[141.42163626777844, -17.443767652538384],
[141.1390526951007, -18.11866049465472],
[141.76166249630998, -19.191819594087534],
[142.12672343455688, -18.993463991745095],
[142.60066821300427, -19.635527944972008],
[144.22723846204613, -19.615139477135415],
[144.79446325477548, -19.162273594087047],
[144.83664502593976, -18.49325539524566],
[146.19074846855875, -18.52331974612335],
[146.14856669739447, -17.6471339800271],
[145.41227187877905, -16.467021816265046],
[145.2984153907584, -14.963631488754993],
[144.45889526222066, -14.23569407353837],
[143.75620868404508, -14.363035605704201],
[143.43675892925222, -12.622931710938804],
[142.85598795797824, -11.845750962388042],
[142.7856850060378, -11.074963207989427],
[142.1236369634961, -11.455778319106788],
[141.59139217612247, -12.564185278189303],
[141.68312895487406, -13.302835278201425],
[141.46364656832824, -13.877513617392141],
[141.66615336403964, -15.03343607355146],
[141.29457654244217, -16.394971044334035]
]
]
},
"properties": {"Area": "Cairns", "Residents": "an_interesting_mob"}
}
]
},
"format": {"type": "json", "property": "features"}
}
],
"projections": [
{
"name": "projection",
"type": "mercator",
"scale": {"signal": "867"},
"center": [{"signal": "144"}, {"signal": "-14"}]
}
],
"marks": [
{
"type": "shape",
"from": {"data": "counties"},
"encode": {"update": {"fill": {"value": "gray"}}},
"transform": [{"type": "geoshape", "projection": "projection"}]
}
]
}