- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
给定一个 data.tsv 文件:
id code name
1 AL Alabama
2 AK Alaska
4 AZ Arizona
5 AR Arkansas
6 CA California
... ... ...
{
"type":"Topology",
"transform":
{
"scale": [0.0015484881821515486,0.0010301030103010299],
"translate":[-5.491666666666662,41.008333333333354]
},
"objects":
{
"states":
{
"type":"GeometryCollection",
"geometries":
[
{"type":"Polygon","arcs":[[0]],"properties":{"code_2":"AL"}},
{"type":"Polygon","arcs":[[1]],"properties":{"code_2":"AK"}}
]
}
},
"arcs":
[
[[2466,9916],[-25,-5],[3,-13]],
[[2357,9852],[1,-2],[1,-2]]
]
}
data.txt#code
和
topojson.txt.objects.states.geometries.properties.code_2
data.txt#name
{"type":"Polygon","arcs":[[0]],"properties":{"code_2":"AL", "name":"Alabama" }},
{"type":"Polygon","arcs":[[1]],"properties":{"code_2":"AK", "name":"Alaska" }},
topojson -o final.json -e data.tsv --id-property=code_2,code -p code_2,state=name -- topojson.json
最佳答案
尝试使用这个:
topojson -o final.json -e data.tsv --id-property=code_2,code -p code_2,state=name -- topojson.json
{
"type": "Topology",
"transform": {
"scale": [
0.000016880209206372492,
0.000007005401010148724
],
"translate": [
-1.8418800213354616,
51.15278777877789
]
},
"objects": {
"states": {
"type": "GeometryCollection",
"geometries": [
{
"type": "Polygon",
"arcs": [
[
0
]
],
"id": "AK",
"properties": {
"code_2": "AK",
"state": "Alaska"
}
}
]
}
},
"arcs": [
[
[
0,
588
],
[
92,
-294
],
[
91,
-294
],
[
-183,
588
]
]
]
}
--id-property name of feature property to promote to geometry id
code_2
使用此选项的属性,您将其提升为功能 ID。
Prepend a + in front of the input property name to coerce its value to a number.
If the properties referenced by --id-property are null or undefined, they are omitted from the output geometry object. Thus, the generated objects may not have a defined ID if the input features did not have a property with the specified name.
+code
和
+code_2
,他们可能是
undefined
,因为您无法转换
AK
将字符串值转换为数字。
Here, the input property "FIPS" is coerced to a number and used as the feature identifier; likewise, the column named "FIPS" is used as the identifier in the CSV file. (If your CSV file uses a different column name for the feature identifier, you can specify multiple id properties, such as
--id-property=+FIPS,+id
.)
code
到
--id-property=code_2,code
选项。这就是映射的制作方式(topojson.json 中的
code_2
和 data.tsv 中的
code
列)。
Then, the output property "unemployment" is generated from the external data file, unemployment.tsv, which defines the input property "rate"
-p code_2,state=name
指定我们将保留
code_2
属性,我们将重命名
name
属性(property)给
state
.
房产 和
外部属性 上述文档 wiki 中的部分对此事提供了相当丰富的信息。
关于json - 如何向 topojson 文件添加属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18444261/
我是一名优秀的程序员,十分优秀!