需要使用d3 geoPath.projection缩放已投影的数据(null) [英] Need to scale already projected data using d3 geoPath.projection(null)
问题描述
基于d3(ver 1.4)文档 https:/ /github.com/d3/d3-geo/blob/master/README.md#geoProjection ,应将d3投影设置为null以使用数据的原始坐标。如果投影看起来正确使用null,我该如何缩放?以下是代码:
Based on d3 (ver 1.4) documentation https://github.com/d3/d3-geo/blob/master/README.md#geoProjection , the d3 projection should be set to null to use the data's raw coordinates. How do I scale if the projection looks correct using null? Here is the code:
var path = d3.geoPath()
.projection(null)
.context(context);
bands.features.forEach(function(d, i) {
context.beginPath();
context.fillStyle = colors[i];
context.globalAlpha = .5;
path(d);
context.fill();
});
我尝试定义自己的投影,但投影看起来不正确。这是代码
I have tried defining my own projection but the projection looks incorrect. Here is the code
var project = d3.geoProjection(function(x,y){
return [x,y]
});
var path = d3.geoPath()
.projection(project)
.context(context);
推荐答案
感谢您的建议。我的问题结果不是规模问题,而是矩阵转换问题。我正在使用d3marchingsquares.isobands软件,我需要在将数据发送到行进方格之前转置我的数据。
Thanks for your suggestion. My problem turned out to not be a scale problem but a matrix transformation issue. I am using the d3marchingsquares.isobands software and I needed to transpose my data prior to sending it into marching squares.
我的项目创建一个类似于 https://earth.nullschool.net/ 但使用谷歌地图。
My project is create a map similar to https://earth.nullschool.net/ but using Google Maps.
我正在调整Roger Veciana的带有d3的geotiff的isobands演示 http://bl.ocks.org/rveciana/de0bd586eafd7fcdfe29227ccbdcd511 。这几乎已经完成但是在调整画布层大小时出现问题。接下来,我将把Danny Cochran的可卷绕帆布层覆盖在温度轮廓上。我更新了Danny Cochran的代码,以使用最新的Google Map版本。
I am adapting Roger Veciana's "Isobands from a geotiff with d3" demo http://bl.ocks.org/rveciana/de0bd586eafd7fcdfe29227ccbdcd511. This is almost complete but having issues resizing the canvas layer. Next I am going to overlay Danny Cochran's windable canvas layer over the temperature contours. I updated Danny Cochran's code to work with the latest Google Map's version.
这篇关于需要使用d3 geoPath.projection缩放已投影的数据(null)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!