我正在尝试制作一个topojson文件,其中使用makefile嵌入csv数据。我正在使用迈克·博斯托克的美国地图册作为指南。
topo/us-counties-10m-ungrouped.json: shp/us/counties.shp
mkdir -p $(dir $@)
topojson
-o us_counties.json
--no-pre-quantization
--post-quantization=1e6
--external-properties=output.csv
--id-property=FIPS
--properties="County=County"
--properties="PerChildrenPos=+PerChildrenPos"
--simplify=7e-7
-- $<
它创建了我需要的topojson,但完全忽略了output.csv文件。以下是它的回报。
{"type":"Polygon","id":"53051","properties":{"code":"53051"},"arcs":[[-22,79,80,-75,81]]}
这是我需要的回报。
{"type":"Polygon","id":"53051","properties":{"code":"53051", "County":"Los Angeles", "PerChildrenPos": 10},"arcs":[[-22,79,80,-75,81]]}
你知道为什么它会忽略csv文件吗?我已经测试过移动它,看看它是否不可访问或其他什么?
提前谢谢。
根据此处的文档:https://github.com/mbostock/topojson/wiki/Command-Line-Reference#external-属性
(如果CSV文件使用不同的列名作为功能标识符,则可以指定多个id属性,例如--id属性=+FIPS,+id。)
似乎您需要将--id-property=FIPS
更改为与CSV列名相对应的内容。
同样适用于--properties="County=County"
我认为应该是--properties County=+County
与--properties="PerChildrenPos=+PerChildrenPos"
相同
应为--properties PerChildrenPos=+PerChildrenPos
对于--external-properties=output.csv
应该是--external-properties output.csv
基本上,参数不需要以=
符号为前缀。