我意识到有一些这方面的例子,但我实际上没有运气让房产有效,所以我想在这个具体的例子中我会问。我想从我的csv获取属性,并通过公共ID将其附加到json文件。
沿着
行topojson -o final.json -e waste.csv -p population=population -p waste=waste, -p country=country -- world.json
我的world.json文件如下(来自Mike Bostock)
{"type":"Topology",
"objects":{"countries":
{"type":"GeometryCollection","bbox":[-179.99999999999997,-90.00000000000003,180.00000000000014,83.64513000000001],
"geometries":[{"type":"Polygon","id":4,"arcs":[[0,1,2,3,4,5]]},
{"type":"MultiPolygon","id":24,"arcs":[[[6,7,8,9]],[[10,11,12]]]},
{"type":"Polygon","id":8,"arcs":[[13,14,15,16,17]]},{"type":"Polygon","id":784,"arcs":[[18,19,20,21,22]]}
以下是我的waste.csv:
id,country,income,region,population,wpc,waste,future_pop,future_urban_pop,future_wpc,future_waste,organic,paper,plastic,glass,metal,other
8,Albania,LMI,ECA,"1,418,524",0.77,"1,088","3,488,000","2,006,000",1.2,"2,407",38,10,8,5,5,34
12,Algeria,LMI,MENA,"19,225,335",1.21,"23,288","42,882,000","31,778,000",1.45,"46,078",70,10,5,1,2,12
答案 0 :(得分:0)
据我所知,您指定的--id-property应该是属性
- 要提升为几何id的要素属性的id属性名称。默认情况下,topojson保留输入要素的id属性。如果您希望在转换为TopoJSON时将属性提升为功能ID,请使用--id-property参数。
{"type":"Topology",
"objects":{"countries":
{"type":"GeometryCollection","bbox":[-179.99999999999997,-90.00000000000003,180.00000000000014,83.64513000000001],
"geometries":[{"type":"Polygon",properties:{"id":4},"arcs":[[0,1,2,3,4,5]]},
{"type":"MultiPolygon",properties:{"id":24},"arcs":[[[6,7,8,9]],[[10,11,12]]]},
{"type":"Polygon",properties:{"id":8},"arcs":[[13,14,15,16,17]]},{"type":"Polygon","id":784,"arcs":[[18,19,20,21,22]]}
topojson -o final.json -e waste.csv --id-property = + id,+ id -p population = population -p waste = waste,-p country = country - world.json