【问题标题】:TopoJson makefile ignoring external properties fileTopoJson makefile 忽略外部属性文件
【发布时间】:2016-05-01 23:00:51
【问题描述】:

我正在尝试使用 makefile 制作一个嵌入了 csv 数据的 topojson 文件。我使用 Mike Bostock 的 us-atlas 作为指南。

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 文件,我已经测试过移动它以查看它是否无法访问或其他什么?

提前致谢。

【问题讨论】:

    标签: csv d3.js topojson


    【解决方案1】:

    根据此处的文档:https://github.com/mbostock/topojson/wiki/Command-Line-Reference#external-properties

    (如果您的 CSV 文件对特征标识符使用不同的列名,您可以指定多个 id 属性,例如 --id-property=+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 \

    基本上参数不需要以=符号作为前缀。

    【讨论】:

    • 我尝试了这些建议,但它仍然没有像应有的那样添加数据。为了保持一致性,我还尝试将 .csv 文件中的 id 更改为 FIPS,但它仍然无法读取
    • 发现我使用自定义 python 脚本抓取的数据中有不必要的空格。教训:确保数据匹配!我的错,但不在我认为的地方。这个答案也增加了我的成功,所以谢谢@paradite!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-02-10
    • 2017-04-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多