我已经成功加载了将要素集加载到的geoJSON文件中
d3.geo.path()
Run Code Online (Sandbox Code Playgroud)
我当前实现的问题是它开始缩放,使得路径是一个点,我必须每次放大.现在我知道有很多方法可以正确设置缩放级别,但我希望能够使用
d3.geo.bounds()
Run Code Online (Sandbox Code Playgroud)
鉴于以下geoJSON功能:
json.features[0]:
Object
geometry: Object
coordinates: Array[2]
0: -71.248913
1: 44.078426
length: 2
__proto__: Array[0]
type: "Point"
__proto__: Object
id: 2
type: "Feature"
__proto__: Object
Run Code Online (Sandbox Code Playgroud)
和
json.features[1]:
Object
geometry: Object
coordinates: Array[2]
0: -71.249021
1: 44.078387
length: 2
__proto__: Array[0]
type: "Point"
__proto__: Object
id: 3
type: "Feature"
__proto__: Object
Run Code Online (Sandbox Code Playgroud)
如果我执行
d3.geo.bounds(json.features)
Run Code Online (Sandbox Code Playgroud)
我得到无限的界限:
d3.geo.bounds(json.features)
[
Array[2]
0: Infinity
1: Infinity
length: 2
__proto__: Array[0]
,
Array[2]
0: -Infinity
1: -Infinity
length: 2
__proto__: Array[0]
]
Run Code Online (Sandbox Code Playgroud)
我不确定是什么问题,显然我有一个比上面更大的数据集,但我只是想了解输出.这个输出对我来说没有意义,显然缺少关于d3处理geoJSON数据的简单方法.任何帮助以获得工作的帮助都会有所帮助. …
我目前接口到提供协议缓冲区的服务器.我可能会收到大量的邮件.目前我的过程是读取协议缓冲区并将它们转换为Pandas DataFrame(一般不是必要的步骤,但Pandas提供了分析数据集的好工具):
pandas.DataFrame.from_records
获取DataFrame这很好用,但是,鉴于我从protobuf中读取的大量消息,转换为字典然后转换为pandas是非常低效的.我的问题是:是否有可能创建一个可以使python protobuf对象看起来像字典的类?也就是说,删除步骤2.任何引用或伪代码都会有所帮助.